Forum: Ruby on Rails Liquid templates and RJS

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Roberto S. (Guest)
on 2006-01-24 22:22
(Received via mailing list)
Does anybody know whether Liquid templates can be combined with RJS ?
Nshbrown N. (Guest)
on 2006-01-25 02:31
(Received via mailing list)
Liquid templates can in its rudimentary state be used within an RJS
template, but it really doesn't make much sense, from that perspective.

The purpose of a Liquid template is to remove the ability to access Ruby
directly, but still providing adequate access to variables and being
able to
manipulate or loop through those data sets. So to use Liquid syntax
an RJS template really defeats the purpose of what its intention is as a
template implies the ability to use Ruby directly.

Now, from the other perspective on whether you can use the RJS
within a Liquid template is another story. How complicated when it gets
to it is up to you, but the concept is that it can be done by wrapping
the RJS methods (page.replace_html, page.remove, etc) with custom Liquid
template filters like so..

{{ 'New title' | replace_html: 'elementId' }}

To go even further, I suppose you could even use the configured
supplied to the Liquid template within each expression like so:

{{ | replace_html: 'elementId' }}

So it really depends on what your perspective is :)


 Nathaniel S. H. Brown                 
This topic is locked and can not be replied to.