Sha256: 5d375ed1aa746a89995728a8c9e3560bf0291df9ce8ff7ac340b8e6bd9ed0476
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true # Tag for injecting template rendering. Example tag: # {{cms:template template/path}} # This expands into something like this: # <%= render template: "template/path" %> # Whitelist is can be used to control what templates are available. # class ComfortableMediaSurfer::Content::Tags::Template < ComfortableMediaSurfer::Content::Tag attr_reader :path def initialize(context:, params: [], source: nil) super @path = params[0] return if @path.present? raise Error, 'Missing template path for template tag' end # we output erb into rest of the content def allow_erb? true end def content format('<%%= render template: %<path>p %%>', path: path) end def render whitelist = ComfortableMediaSurfer.config.allowed_templates if whitelist.is_a?(Array) whitelist.member?(@path) ? content : '' else content end end end ComfortableMediaSurfer::Content::Renderer.register_tag( :template, ComfortableMediaSurfer::Content::Tags::Template )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_media_surfer-3.0.0 | lib/comfortable_media_surfer/content/tags/template.rb |