Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token-like patterns no longer treated as templates #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mogsie
Copy link

@mogsie mogsie commented Dec 21, 2016

If you have templates that have typos in their includes, the use of the
Twig_Loader_String causes the typo to be echoed out:

{% include "foo" %}

results in the string "foo" to be printed out unless "foo" is a twig
template.

This change causes "foo" to no longer be printed out, but template
generation to fail, because "foo" is not present.

This change also allows more of the twig features to be used, such as
conditional includes and dynamic includes:

{% set foo = "something" %}

{% include [ foo, "fallback" ] %}

Before this change, the string "something" would always be printed.
After the change, either the template "something" is included,
otherwise, the template "fallback" is included, or else an error is
raised:

Twig_Error_Loader: Unable to find one of the following templates:
"something", "fallback"

If you have templates that have typos in their includes, the use of the
Twig_Loader_String causes the typo to be echoed out:

    {% include "foo" %}

results in the string "foo" to be printed out unless "foo" is a twig
template.

This change causes "foo" to no longer be printed out, but template
generation to fail, because "foo" is not present.

This change also allows more of the twig features to be used, such as
conditional includes and dynamic includes:

    {% set foo = "something" %}

    {% include [ foo, "fallback" ] %}

Before this change, the string "something" would always be printed.
After the change, either the template "something" is included,
otherwise, the template "fallback" is included, or else an error is
raised:

    Twig_Error_Loader: Unable to find one of the following templates:
    "something", "fallback"
@mogsie
Copy link
Author

mogsie commented Dec 21, 2016

To be completely honest I expect this might break some pattern libraries, because of typos in obscure twig files. So it might be that this behaviour should be "opt-in". I wanted to do that, but I was unsure of the best way of providing this opt-in-ness, or if it is a good idea at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant