Sha256: 63228276fc192e5f5f37e7fb7044b6b0b9bb16027d8f50624f4d23fba9b675ab

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

class ComfyPress::Tag::Partial
  include ComfyPress::Tag
  
  def self.regex_tag_signature(identifier = nil)
    identifier ||= /[\w\/\-]+/
    /\{\{\s*cms:partial:(#{identifier}):?(.*?)\s*\}\}/
  end
  
  def content
    ps = params.collect_with_index{|p, i| ":param_#{i+1} => '#{p}'"}.join(', ')
    "<%= render :partial => '#{identifier}'#{ps.blank?? nil : ", :locals => {#{ps}}"} %>"
  end
  
  def render
    whitelist = ComfyPress.config.allowed_partials
    if whitelist.is_a?(Array)
      content if whitelist.member?(identifier)
    else
      content
    end
  end
  
end

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
comfypress-0.1.4 db/lib/comfypress/tags/partial.rb
comfypress-0.1.4 lib/comfypress/tags/partial.rb
comfypress-0.1.3 lib/comfypress/tags/partial.rb