Class: Liquid::ParseEnvironment
- Inherits:
-
Object
- Object
- Liquid::ParseEnvironment
- Includes:
- Singleton
- Defined in:
- app/lib/liquid/parse_environment.rb
Defined Under Namespace
Classes: RawFallbackTemplate
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ParseEnvironment
constructor
A new instance of ParseEnvironment.
- #parse(content) ⇒ Object
Constructor Details
#initialize ⇒ ParseEnvironment
Returns a new instance of ParseEnvironment.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/lib/liquid/parse_environment.rb', line 8 def initialize @environment = Liquid::Environment.new @environment.error_mode = :warn @environment.register_filter(Liquid::Filters::Helpers) @environment.register_tag('image_tag', Liquid::Tags::Image) @environment.register_tag('partial', Liquid::Tags::Partial) @environment.register_tag('floor_heating_calculator', Liquid::Tags::FloorHeatingCalculator) @environment.register_tag('snow_melting_calculator', Liquid::Tags::SnowMeltingCalculator) @environment.register_tag('electricity_cost', Liquid::Tags::ElectricityCost) @environment.register_tag('product_price', Liquid::Tags::ProductPrice) end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
6 7 8 |
# File 'app/lib/liquid/parse_environment.rb', line 6 def environment @environment end |
Class Method Details
.parse(content) ⇒ Object
29 30 31 |
# File 'app/lib/liquid/parse_environment.rb', line 29 def self.parse(content) instance.parse(content) end |
Instance Method Details
#parse(content) ⇒ Object
22 23 24 25 26 27 |
# File 'app/lib/liquid/parse_environment.rb', line 22 def parse(content) Liquid::Template.parse(content, environment: @environment) rescue Liquid::SyntaxError => e ErrorReporting.error(e, context: "Liquid parse failed for content (#{content.to_s[0, 80]}...)") RawFallbackTemplate.new(content) end |