Sha256: 2d7f41555a3d5d6eddc4a8291c9db8a14f96d20a427d6062afb25003a6b57a4e
Contents?: true
Size: 886 Bytes
Versions: 4
Compression:
Stored size: 886 Bytes
Contents
# frozen_string_literal: true module Archangel ## # Template Liquid render service # class TemplateRenderService < RenderService ## # Render the Liquid content for template # # @return [String] the rendered content for template # def call template_content = build_template(template) liquid = ::Liquid::Template.parse(template_content) liquid.send(:render, stringify_assigns, liquid_options).html_safe end protected def build_template(template) template_content = current_template_content(template) unless /\{\{\s*content_for_layout\s*\}\}/.match?(template_content) template_content += "{{ content_for_layout }}" end template_content end def current_template_content(template) return "{{ content_for_layout }}" if template.blank? template.content end end end
Version data entries
4 entries across 4 versions & 1 rubygems