Sha256: 0badc6a01030a281382426a41e2ea57a2c17446806544ce732c2e065d505278f

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require_relative 'i18n_decorator'

module Locomotive
  module Steam
    module Decorators

      class TemplateDecorator < I18nDecorator

        def liquid_source
          if respond_to?(:template_path) && template_path
            source_from_template_file
          else
            self.source
          end
        end

        private

        def source_from_template_file
          source = File.open(template_path).read.force_encoding('utf-8')

          if match = source.match(FRONTMATTER_REGEXP)
            source = match[:template]
          end

          if template_path.ends_with?('.haml')
            Haml::Engine.new(source).render
          else
            source
          end
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/decorators/template_decorator.rb