I have a JTwig (java flavor of twig) template like
SomeMagazine.twig:
bla bla bla, and I quote:
{% block quote %}
{% endblock%}
and some more bla bla bla and so on
The child template invoking this one looks something like:
MagQuote.twig:
{% extends 'SomeMagazine.twig' %}
{% block quote %}
{% include 'QuotAuthTemplate.twig' with { auth : quote.author } %}
{% include 'QuotTextTemplate.twig' with { qtxt : quote.content } %}
{% endblock %}
- I would like to get all contents of the
quote
block with 1 tab at the begining - Notice I cannot tab them in
MagQuote.twig
since it is composed by other templates so tabbing the template inclusion would only tab the first tab of the entire other template Specifically for JTwig I tried creating my own function to tab contents (
SimpleJtwigFunction
, and add it to theEnvironmentConfiguration
at template instantiation) but I cannot figure out how to invoke it over the template contents since- I cannot (don't know how to) save them in a variable so that I can invoke my method over it; neither this
{% set 'tmpltCnt' = {% include ...
nor this{% set 'tmpltCnt' = include ...
syntax works (and I cannot find it) - I cannot tab the contents at the
QuotAuthTemplate.twig
andQuotTextTemplate.twig
since they are used at some other places that require no tabs... - I cannot (don't know how to) call the function over the include itself; neither this
{{ myTabbingMthd({% include ...
nor this{{ myTabbingMthd(include ...
syntax works (and I cannot find it)
- I cannot (don't know how to) save them in a variable so that I can invoke my method over it; neither this
maybe just following the wrong approach here?...
Answer (sort of...)
Best solutions o far has been to add some "tags"; A unique-ish string that I can later use for pattern matching to later perform the line by line tabbing and replacing it on the resulting string removing the tags... Still hope someone comes up with something better since...
Issues for this solution
If you happen to be in the need (as I am) of having an indented block within another then the pattern matching will get confused, requiring you to either defined different tags for each, otherwise look this other answer for similar situations