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

Avoid creating unnecessary Twig_Markup instances #638

Merged
merged 1 commit into from
Feb 18, 2012

Conversation

Seldaek
Copy link
Contributor

@Seldaek Seldaek commented Feb 17, 2012

This allows testing for falsiness of an empty output:

{% set foo %}{% block lala %}{% endblock %}{% endset %}

{% if foo %}
   some output with {{ foo }} 
{% endif %}

Currently this requires {% if foo|length %} since the set tag will always return a Twig_Markup.

fabpot added a commit that referenced this pull request Feb 18, 2012
Commits
-------

e4590d0 Avoid creating unnecessary Twig_Markup instances, allows testing for falsiness of empty output

Discussion
----------

Avoid creating unnecessary Twig_Markup instances

This allows testing for falsiness of an empty output:

```jinja
{% set foo %}{% block lala %}{% endblock %}{% endset %}

{% if foo %}
   some output with {{ foo }}
{% endif %}
```

Currently this requires `{% if foo|length %}` since the set tag will always return a Twig_Markup.
@fabpot fabpot merged commit e4590d0 into twigphp:master Feb 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants