Skip to content

Commit

Permalink
Merge pull request #10 from Minstel/Improve_pushing_out_tags
Browse files Browse the repository at this point in the history
Improve pushing out tags
  • Loading branch information
jasny authored Mar 9, 2017
2 parents 2c720ff + c1ac091 commit 62ad98a
Show file tree
Hide file tree
Showing 17 changed files with 1,037 additions and 345 deletions.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,49 @@ If we obtain an empty tag pair in common ancestor node, we remove it. So the fin
</p>
```

### 4. Fix for tables
### 4. Improve tags

After previous steps all tags are fixed, so no DOM nodes will partially disappear if some sections get hidden. But we can still do some improvement for tags:

- merge same sibling tag sections
- rise section from the containing node, if section contains all node's content

#### 4a. Merge same sections

If same tag section repeats more than one time, and there is no data between these sections, we can merge them into single section. This improves readability of document and it's processing speed. Consider the example:

```hmtl
<div>
{{#tag}}<span>Data</span>{{/tag}}
{{#tag}}<span>Data</span>{{/tag}}
</div>
```

After merging it becomes:

```hmtl
<div>
{{#tag}}
<span>Data</span>
<span>Data</span>
{{/tag}}
</div>
```

#### 4b. Rise section from it's parent node

If section from previous example gets hidden, we'll end up with empty `div` node. It's of no use, so it would be better if it was hidden together with section. So we should include it inside section, and result of this operation is:

```hmtl
{{#tag}}
<div>
<span>Data</span>
<span>Data</span>
</div>
{{/tag}}
```

### 5. Fix for tables

Above steps might lead to the tags appearing in tables outside table cells, and that will break visual table structure. So we move such tags inside table cells.

Expand Down Expand Up @@ -453,6 +495,8 @@ becomes
</table>
```

That's it. Now we have good user-friendly template:)

## Limitations

Currently the following sections structures are supported:
Expand Down
Loading

0 comments on commit 62ad98a

Please sign in to comment.