Sha256: 16ebb1432221a7326f1e3a6b6e38c9197845c3ee32dd34b104ef43dd593bded4

Contents?: true

Size: 586 Bytes

Versions: 3

Compression:

Stored size: 586 Bytes

Contents

class ComfyPress::Tag::Helper
  include ComfyPress::Tag
  
  BLACKLIST = %w(eval class_eval instance_eval render)
  
  def self.regex_tag_signature(identifier = nil)
    identifier ||= /[\w\-]+/
    /\{\{\s*cms:helper:(#{identifier}):?(.*?)\s*\}\}/
  end
  
  def content
    "<%= #{identifier}(#{params.collect{|p| "'#{p}'"}.join(', ')}) %>"
  end
  
  def render
    whitelist = ComfyPress.config.allowed_helpers
    if whitelist.is_a?(Array)
      content if whitelist.map!(&:to_s).member?(identifier)
    else 
      content unless BLACKLIST.member?(identifier)
    end
  end
  
end

Version data entries

3 entries across 2 versions & 1 rubygems

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