stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 223 forks source link

Added indent filter #188

Closed ilyapuchka closed 6 years ago

ilyapuchka commented 6 years ago

With this filter it is possible to indent content either of variable or included from another template.

Examples:

Indented text: {{ "first line\nsecond line"|indent:2,"\t"}}

will render:

Indented text: first line
\t\tsecond line

With filter tag indentation can be also applied to included template content:

Included text: {% filter indent:2 %}{% include "text.html" %}{% endfilter %}

will render:

Included text: first line
  second line

Resolves #95

ilyapuchka commented 6 years ago

@kylef all your comments addressed, thanks for taking time to review this =)

kylef commented 6 years ago

I think one was missed (documentation): https://github.com/kylef/Stencil/pull/188#pullrequestreview-90352354, otherwise good to go.

ilyapuchka commented 6 years ago

Ah, yes, didn't notice that. Documentation should be rebuilt for other PR's too, so I was thinking to do it later with one PR, but can do it now too.

kylef commented 6 years ago

I'm fine with that too, so will merge when CI is finished and you can make a separate PR.

AliSoftware commented 6 years ago

\cc @djbe we should now use that instead of our {{sp}} trick in our templates 😉

ilyapuchka commented 6 years ago

@kylef this is ready to be merged