Module: CustomEmails::Templatable::ClassMethods
- Defined in:
- lib/custom_emails/templatable.rb
Instance Method Summary collapse
-
#interpolate(content, context) ⇒ Object
Use liquid to get the result of template interpretation.
-
#valid_template?(content) ⇒ Boolean
Checks if a content is valid for interpolation.
Instance Method Details
#interpolate(content, context) ⇒ Object
Use liquid to get the result of template interpretation.
24 25 26 27 28 29 30 31 |
# File 'lib/custom_emails/templatable.rb', line 24 def interpolate(content, context) template = ::Liquid::Template.parse(content) if template.errors.empty? template.render(context) else content end end |
#valid_template?(content) ⇒ Boolean
Checks if a content is valid for interpolation.
12 13 14 15 16 17 |
# File 'lib/custom_emails/templatable.rb', line 12 def valid_template?(content) return true if content.blank? template = ::Liquid::Template.parse(content) template.errors.empty? end |