Class: Bunto::Assets::Liquid::Tag::Parser
- Inherits:
-
Object
- Object
- Bunto::Assets::Liquid::Tag::Parser
- Extended by:
- Forwardable
- Defined in:
- lib/bunto/assets/liquid/tag/parser.rb
Defined Under Namespace
Classes: UnescapedColonError, UnknownProxyError
Constant Summary collapse
- ACCEPT =
{ "css" => "text/css", "js" => "application/javascript" }
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#raw_args ⇒ Object
readonly
Returns the value of attribute raw_args.
Instance Method Summary collapse
-
#initialize(args, tag, processed: false, raw_args: nil) ⇒ Parser
constructor
——————————————————————.
-
#parse_liquid(context) ⇒ Object
——————————————————————.
-
#proxies ⇒ Object
——————————————————————.
-
#proxies? ⇒ Boolean
——————————————————————.
-
#to_html ⇒ Object
——————————————————————.
Constructor Details
#initialize(args, tag, processed: false, raw_args: nil) ⇒ Parser
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 61 def initialize(args, tag, processed: false, raw_args: nil) if processed && raw_args @args = args @raw_args = raw_args @tag = tag elsif processed && !raw_args raise ArgumentError, "You must provide raw_args if you pre-process." \ "Please provide the raw args." else @tag = tag @raw_args = args parse_raw set_accept end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
26 27 28 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 26 def args @args end |
#raw_args ⇒ Object (readonly)
Returns the value of attribute raw_args.
26 27 28 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 26 def raw_args @raw_args end |
Instance Method Details
#parse_liquid(context) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 81 def parse_liquid(context) return self unless context.is_a?(Object::Liquid::Context) liquid = context.registers[:site].liquid_renderer.file("(bunto:assets)") out = parse_hash_liquid(to_h, liquid, context) self.class.new(out, @tag, raw_args: @raw_args, \ processed: true) end |
#proxies ⇒ Object
99 100 101 102 103 104 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 99 def proxies keys = (args.keys - Proxies.base_keys - [:file, :html]) args.select do |key, _| keys.include?(key) end end |
#proxies? ⇒ Boolean
108 109 110 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 108 def proxies? proxies.any? end |
#to_html ⇒ Object
91 92 93 94 95 |
# File 'lib/bunto/assets/liquid/tag/parser.rb', line 91 def to_html (self[:html] || {}).map do |key, val| %{ #{key}="#{val}"} end.join end |