Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safe ERB Language?

I wonder if there is a safe template that reassemble ERB. ERB is very easy to use, but the deadly part to use that in a CMS is the over powerful access (you can just write some really nasty stuff with that in a matter of seconds...) So I wonder if there is any chance such language exist.

Please I don't want radius/liquid..... writing extension for that is too much trouble and the template syntax itself is just not my cup of tea... I would want to avoid it if ever possible.

Update: This is not perfect (as its not erb) but seems way much better than Liquid: http://github.com/scottpersinger/laminate

You have to use Lua for your template, but Lua is already a lot better than trying to use liquid (which disable you from doing a simple assignment syntax...)

like image 654
William Yeung Avatar asked Sep 09 '26 02:09

William Yeung


1 Answers

Although you wrote "Please I don't want radius/liquid", I don't understand your reluctance. Just go to the Liquid page and see how easy it is:

gem install liquid

Here is an example snippet:

<ul id="products">
  {% for product in products %}
    <li>
      <h2>{{ product.title }}</h2>
      Only {{ product.price | format_as_money }}

      <p>{{ product.description | prettyprint | truncate: 200  }}</p>
    </li>
  {% endfor %}
</ul>

And, to use it:

Liquid::Template.parse(template).render 'products' => Product.find(:all)
like image 95
David J. Avatar answered Sep 11 '26 15:09

David J.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!