Sha256: 44444a96e54a214c1d079ede9b714ee2761b639ccc2f6b1fd639faaeabc0a838
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
# Tag for injecting partials. Example tag: # {{cms:partial path/to/partial, foo: bar, zip: zoop}} # This expands into a familiar: # <%= render partial: "path/to/partial", locals: {foo: bar, zip: zoop} %> # Whitelist is can be used to control what partials are renderable. # class ComfortableMexicanSofa::Content::Tag::Partial < ComfortableMexicanSofa::Content::Tag attr_reader :path, :locals def initialize(context, params_string) super @locals = params.extract_options! @path = params[0] unless @path.present? raise Error, "Missing path for partial tag" end end # we output erb into rest of the content def allow_erb true end def content "<%= render partial: \"#{@path}\", locals: #{@locals} %>" end def render whitelist = ComfortableMexicanSofa.config.allowed_partials if whitelist.is_a?(Array) whitelist.member?(@path) ? content : "" else content end end end ComfortableMexicanSofa::Content::Renderer.register_tag( :partial, ComfortableMexicanSofa::Content::Tag::Partial )
Version data entries
4 entries across 4 versions & 1 rubygems