Forum: Ruby on Rails Liquid templates and RJS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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
within
an RJS template really defeats the purpose of what its intention is as a
RJS
template implies the ability to use Ruby directly.

Now, from the other perspective on whether you can use the RJS
functionality
within a Liquid template is another story. How complicated when it gets
down
to it is up to you, but the concept is that it can be done by wrapping
all
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
variables
supplied to the Liquid template within each expression like so:

{{ user.name | replace_html: 'elementId' }}

So it really depends on what your perspective is :)

-Nb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Nathaniel S. H. Brown                           http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This topic is locked and can not be replied to.