Class: Faalis::Liquid::Tag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Faalis::Liquid::Tag
- Defined in:
- lib/faalis/liquid/tag.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
- .argument(options) ⇒ Object
- .name ⇒ Object
-
.tag_name(name) ⇒ Object
This method produce the ‘tag_name` DSL which is mandatory for each tag and defines the tag name that the tag class should be registered with.
Instance Method Summary collapse
-
#initialize(name, args, options) ⇒ Tag
constructor
A new instance of Tag.
Constructor Details
#initialize(name, args, options) ⇒ Tag
Returns a new instance of Tag.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/faalis/liquid/tag.rb', line 25 def initialize(name, args, ) super if !arguments.empty? && (args.nil? || args.empty?) count = arguments.length raise ArgumentError.new "'#{count}' argument(s) is/are needed for '#{self.class.name}' tag." end @direction = ::Faalis::I18n.direction(::I18n.locale) @args = args.split(',').map do |x| x.strip.tr('""', '').tr("''", '') end @params = {} arguments.each_with_index do |arg, index| @params[arg[:name]] = @args.fetch(index, arg[:default]) end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/faalis/liquid/tag.rb', line 5 def arguments @arguments end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/faalis/liquid/tag.rb', line 5 def params @params end |
Class Method Details
.argument(options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/faalis/liquid/tag.rb', line 18 def self.argument() raise ArgumentError.new "'name' is mandatory for argument in '#{self.class.name}'" if [:name].nil? @arguments ||= [] @arguments << end |
.name ⇒ Object
14 15 16 |
# File 'lib/faalis/liquid/tag.rb', line 14 def self.name @@name end |
.tag_name(name) ⇒ Object
This method produce the ‘tag_name` DSL which is mandatory for each tag and defines the tag name that the tag class should be registered with
10 11 12 |
# File 'lib/faalis/liquid/tag.rb', line 10 def self.tag_name(name) @@name = name end |