class Jekyll::VignetteTag

Public Class Methods

new(tag_name, markup, tokens) click to toggle source
Calls superclass method
# File lib/dsm-portfolio-plugin.rb, line 164
def initialize(tag_name, markup, tokens)
    super
end

Public Instance Methods

render(context) click to toggle source
Calls superclass method
# File lib/dsm-portfolio-plugin.rb, line 168
def render(context)
    # Edge case - work around to prevent excerpt rendering from producing extra page meta.
    if caller.any? { |trace| trace.include? 'jekyll/excerpt' }
        return
    end

    # Check for existence of vignette iterations.
    if !context['page']['vignettes']
        context['page']['vignettes'] = []

        # Check for project data.
        if context['page']['project_code']
            project = context.registers[:site].data['projects'].select {|p| p['id'] == context['page']['project_code']} [0]
            
            # Add target competencies.
            if project
                context['page']['targets'] = project['targets']
            end
        end
    end

    # Create a new iteration.
    context['active_vignette'] = {
        'competencies': []
    }

    # Add it to the array.
    context['page']['vignettes'].push(context['active_vignette'])

    # Render text as normal.
    rendered = super
    # Wrap in page-specific markup.
    classString = 'vignette-block'
    if context['page']['vignettes'].size == 1
        classString += ' active'
    end
    "<div class=\"#{classString}\" id=\"block-#{context['page']['vignettes'].size - 1}\">#{rendered}</div>"
end