Class: Bunto::Assets::Liquid::Tag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Bunto::Assets::Liquid::Tag
- Defined in:
- lib/bunto/assets/liquid/tag/parser.rb,
lib/bunto/assets/liquid/tag.rb,
lib/bunto/assets/liquid/tag/proxies.rb,
lib/bunto/assets/liquid/tag/defaults.rb,
lib/bunto/assets/liquid/tag/proxied_asset.rb,
lib/bunto/assets/liquid/tag/defaults/image.rb
Overview
Examples:
- {% tag value argument:value %}
- {% tag value "argument:value" %}
- {% tag value argument:"I have spaces" %}
- {% tag value argument:value\:with\:colon %}
- {% tag value argument:"I can even escape \\: here too!" %}
- {% tag value proxy:key:value %}
Defined Under Namespace
Modules: Defaults, Proxies Classes: AssetNotFoundError, Parser, ProxiedAsset
Constant Summary collapse
- AcceptableTags =
Tags that we allow our users to use.
%W( img image javascript asset_source stylesheet asset_path style asset css js ).freeze
- Tags =
The HTML version of every tag that we accept.
{ "css" => %{<link type="text/css" rel="stylesheet" href="%s"%s>}, "js" => %{<script type="text/javascript" src="%s"%s></script>}, "img" => %{<img src="%s"%s>} }.freeze
- Alias =
Allows us to normalize tags so we can simplify logic.
{ "image" => "img", "stylesheet" => "css", "javascript" => "js", "style" => "css" }.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
-
#initialize(tag, args, tokens) ⇒ Tag
constructor
——————————————————————–.
-
#render(context) ⇒ Object
——————————————————————– NOTE: We only attach to the regenerator if you are using digested assets, otherwise we forego any association with it so that we keep your builds ultra fast, this is ideal in dev.
Constructor Details
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
17 18 19 |
# File 'lib/bunto/assets/liquid/tag.rb', line 17 def args @args end |
Instance Method Details
#render(context) ⇒ Object
NOTE: We only attach to the regenerator if you are using digested
assets, otherwise we forego any association with it so that we keep
your builds ultra fast, this is ideal in dev. Disable digests and
let us process independent so the entire site isn't regenerated
because of a single asset change.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/bunto/assets/liquid/tag.rb', line 90 def render(context) site = context.registers[:site] page = context.registers.fetch(:page, {}) args = @args.parse_liquid(context) sprockets = site.sprockets page = page["path"] asset = find_asset(args, sprockets) add_as_bunto_dependency(site, sprockets, page, asset) process_tag(args, sprockets, asset) rescue => e capture_and_out_error( site, e ) end |