Class: MyTagTemplate::MyTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- MyTagTemplate::MyTag
- Defined in:
- jekyll_tag_template.rb
Overview
This class implements the Jekyll tag functionality
Instance Method Summary collapse
-
#initialize(tag_name, arguments, tokens) ⇒ void
constructor
Constructor.
-
#render(context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
Constructor Details
#initialize(tag_name, arguments, tokens) ⇒ void
Constructor.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'jekyll_tag_template.rb', line 35 def initialize(tag_name, arguments, tokens) super(tag_name, arguments, tokens) MyTagTemplate.log.info "tag_name [#{tag_name.class}] = '#{tag_name}' [#{tag_name.class}]".green MyTagTemplate.log.info "arguments [#{arguments.class}] = '#{arguments}'".green # @site = context.registers[:site] # This variable is handy but not required # @config = @site.config # This variable is handy but not required # @mode = @config['env']['JEKYLL_ENV'] # This variable is handy but not required # MyTagTemplate.log.info "mode=#{@mode}".green @arguments = arguments @arguments = '' if @arguments.nil? || @arguments.empty? end |
Instance Method Details
#render(context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'jekyll_tag_template.rb', line 51 def render(context) @site = context.registers[:site] @config = @site.config @mode = @config['env']['JEKYLL_ENV'] MyTagTemplate.log.info "mode='#{@mode}'".green @page = context.registers[:page] MyTagTemplate.log.info "page.path='#{@page.path}'".green MyTagTemplate.log.info "page.url='#{@page.url}'".green <<~HEREDOC <p style="color: green; background-color: yellow; padding: 1em; border: solid thin grey;"> #{@arguments} </p> HEREDOC end |