Class: Archangel::Liquid::Tags::WidgetTag
- Inherits:
-
ApplicationTag
- Object
- Liquid::Tag
- ApplicationTag
- Archangel::Liquid::Tags::WidgetTag
- Defined in:
- lib/archangel/liquid/tags/widget_tag.rb
Overview
Widget custom tag for Liquid
Example
{% widget "widget-name" %}
{% widget 'widget-name' %}
{% widget -name %}
Constant Summary
Constants inherited from ApplicationTag
ApplicationTag::ASSET_ATTRIBUTES_SYNTAX, ApplicationTag::ASSET_SYNTAX, ApplicationTag::KEY_VALUE_ATTRIBUTES_SYNTAX, ApplicationTag::SLUG_ATTRIBUTES_SYNTAX, ApplicationTag::SLUG_SYNTAX, ApplicationTag::URL_ATTRIBUTES_SYNTAX
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ WidgetTag
constructor
Widget for Liquid.
-
#render(context) ⇒ String
Render the Widget.
Constructor Details
#initialize(tag_name, markup, options) ⇒ WidgetTag
Widget for Liquid
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/archangel/liquid/tags/widget_tag.rb', line 22 def initialize(tag_name, markup, ) super match = SLUG_SYNTAX.match(markup) if match.blank? raise ::Liquid::SyntaxError, Archangel.t("errors.syntax.widget") end @slug = ::Liquid::Variable.new(match[:slug], ).name end |
Instance Method Details
#render(context) ⇒ String
Render the Widget
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/archangel/liquid/tags/widget_tag.rb', line 40 def render(context) return if slug.blank? = (context["site"].object) return if .blank? = (.content, context.environments.first) if .design.present? = (.design, ) end end |