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

Raw tag #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Raw tag #60

wants to merge 2 commits into from

Conversation

IJMacD
Copy link

@IJMacD IJMacD commented Jan 5, 2013

A tag which apparently has just been added to django 1.3.

I just came across the scenario where I needed to render jquery-tmpl templates (or similar) within a template of mine. As you may guess jquery-tmpl syntax messes with the tags and variables in h2o templates.

Hence the need for {% raw %} and corresponding {% endraw %} tags.

Anything within these two tags will not be parsed and passed on as though they were plain text all along.

Example:

Hello, {{ name }}
{% raw %}
<script type="text/x-tmpl">
{% for (cat in cats) { %}
    <span>{%=cat.name%}</span>
{% } %}
</script>
{% endraw %}

When rendered with array('name' => "Bob") produces as expected:

Hello, Bob
<script type="text/x-tmpl">
{% for (cat in cats) { %}
    <span>{%=cat.name%}</span>
{% } %}
</script>

$this->type = $type;
$this->content = $content;
$this->result='';
$this->position = $position;
$this->raw = $raw;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to correctly capture the whitespace associated with tokens an extra field capturing the entire match is required.

I have assumed capturing whitespace is important in almost all use cases of {% raw %} tag

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