Liquid templates and RJS

Does anybody know whether Liquid templates can be combined with RJS ?

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 :slight_smile:


 Nathaniel S. H. Brown                 

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs