Rendering Partial in Liquid Layout (Rails3)

I have a liquid template in which I need to render a partial inside.

Please note that @current_page.page_layout.content load the contents from the database.

My fluid layout file is as follows:

 #layouts/public.html.erb <%= Liquid::Template.parse(@current_page.page_layout.content). render('page_content' => yield, 'page_title' => yield(:title)) %> 

and below is my code, which also includes partial

 {{page_content}} {% include 'this_is_the_partial_name' %} 

and i get this error

 Liquid error: This liquid context does not allow includes. 

I tried searching the Internet and found this solution , but still not sure what to enter for this code:

 Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_path) liquid = Liquid::Template.parse(template) 
+4
source share
1 answer

A little late to the party .. but here's how you should use it:

In the initializer (e.g. / config / initializers / liquid.rb) add:

 template_path = Rails.root.join('app/views/snippets') Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_path) 

Add your incomplete file, for example. app/views/snippets/_partial_name.liquid .

Now in your liquid template use:

 {% include 'partial_name' %} 
+9
source

All Articles