Class: ComfortableMexicanSofa::Tag::Helper

Inherits:
Object
  • Object
show all
Includes:
ComfortableMexicanSofa::Tag
Defined in:
lib/comfortable_mexican_sofa/tags/helper.rb

Constant Summary collapse

BLACKLIST =
%w(eval class_eval instance_eval render)

Constants included from ComfortableMexicanSofa::Tag

IDENTIFIER_REGEX, TOKENIZER_REGEX

Instance Attribute Summary

Attributes included from ComfortableMexicanSofa::Tag

#blockable, #identifier, #namespace, #params, #parent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.regex_tag_signature(identifier = nil) ⇒ Object



6
7
8
9
# File 'lib/comfortable_mexican_sofa/tags/helper.rb', line 6

def self.regex_tag_signature(identifier = nil)
  identifier ||= /[\w\-]+/
  /\{\{\s*cms:helper:(#{identifier}):?(.*?)\s*\}\}/
end

Instance Method Details

#contentObject



11
12
13
# File 'lib/comfortable_mexican_sofa/tags/helper.rb', line 11

def content
  "<%= #{identifier}(#{params.collect{|p| "'#{p}'"}.join(', ')}) %>"
end

#renderObject



15
16
17
18
19
20
21
22
# File 'lib/comfortable_mexican_sofa/tags/helper.rb', line 15

def render
  whitelist = ComfortableMexicanSofa.config.allowed_helpers
  if whitelist.is_a?(Array)
    content if whitelist.map!(&:to_s).member?(identifier)
  else 
    content unless BLACKLIST.member?(identifier)
  end
end