Ruby on Rails
HowToRenderTemplatesFromTheDatabaseUsingLiquid

It’s actually not as hard as I had initially thought. What you need to do is render the code FIRST and then send that rendered data to the render method with text. Some example code for you:

Grab the row

@node = Node.find(1)

Parse it’s contents

@template = Liquid::Template.parse(@node.content)</pre>

Send the contents to the render method

render :text => @template.render( 
        'current_time' => Time.now,
        'name' => 'Lance'
      )

Lets say @node.content contains:

Hi {{name}}, the time is {{current_time}}

The output should be:

Hi Lance, the time is Sat Dec 09 15:37:15 Eastern Standard Time 2006

The next step (for me) is figuring out how to cache this. Any thoughts?

-Lance