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 Template Tag #37

Closed
dcramer opened this issue Dec 24, 2010 · 5 comments
Closed

Raw Template Tag #37

dcramer opened this issue Dec 24, 2010 · 5 comments

Comments

@dcramer
Copy link

dcramer commented Dec 24, 2010

It would be great to see a template tag for handling raw code:

{% raw %}
{% this shouldnt get evaluated %}
{% endraw %}

@carolineschnapp
Copy link

This would be needed to use the official jQuery template plugin in Liquid templates: http://api.jquery.com/category/plugins/templates

That plugin uses double curly braces for all its tags, except for the alias ${ output } which is a short version for:

{{= output }}

Adding a “raw” tag may also solve the problem we currently have with Assistly. Assistly lets us use Liquid in replies to customers. That means that design supporters cannot share code snippets in a reply. Anything that uses double curly braces is 'parsed'. We have to create a gist every time we want to share a code snippet with our customers. We cannot use square brackets and ask them to make the substitution. Well, we can, but... that's so painful: “In the above code snippet you must change [[ to double { and ]] to double }.”

@carolineschnapp
Copy link

Just to be clear, the only place you can place a jQuery template is inside a .liquid template, hence the road block. A jQuery template looks like this:

 <script id="my-template"  type="text/x-jquery-tmpl">
   <li>
      <a href="${url}">
         <span class="title">${title}</span>
      </a>
   </li>
 </script>

It's a script tag, so it cannot be placed in a .js file.

As soon as you want to use logic in such template, you have to use the double curly braces notation: http://api.jquery.com/category/plugins/templates

I was thinking about modifying the plugin itself but it's hosted on a CDN and it is updated and improved constantly.

@phaer
Copy link

phaer commented Jun 11, 2011

I'd love to see this feature. It would also help with mustache and other template languages beside jQuery.tmpl().

Because - according to "Liquid for Programmers" - Liquid parses all block tags, we'd have to patch liquid itself. A custom block tag itself can't help here.

@phaer
Copy link

phaer commented Jun 11, 2011

Wrote a proof of concept which i'm using for my jekyll generated site: https://gist.github.com/1020852 . Should be trivial to include it in other projects.

@phaer
Copy link

phaer commented Jun 13, 2011

Well, it seems like there is a little issue in this implementation: If you use {{ variable }} inside a html attribute it gets masked. For example:

<a href="#{{id}}">{{name}}</a>

becomes

<a href="#%7B%7Bid%7D%7D">Test</a>

I'll have a look into this during the next days.

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

No branches or pull requests

4 participants