Class: Liquid::Tags::Partial
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Liquid::Tags::Partial
- Defined in:
- app/lib/liquid/tags/partial.rb
Overview
Library code: partial.
Instance Method Summary collapse
-
#initialize(tag_name, name, tokens) ⇒ Partial
constructor
A new instance of Partial.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, name, tokens) ⇒ Partial
Returns a new instance of Partial.
10 11 12 13 |
# File 'app/lib/liquid/tags/partial.rb', line 10 def initialize(tag_name, name, tokens) super @name = name.strip.remove("'") end |
Instance Method Details
#render(context) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/lib/liquid/tags/partial.rb', line 15 def render(context) new_context = context.environments.first # Load up from file system partial_path = Rails.root.join('app', 'lib', 'liquid', 'partials', "#{@name}.liquid") content = File.read(partial_path) Liquid::ParseEnvironment.parse(content).render(new_context).html_safe end |