Class: DocTemplate::Tags::PdTag

Inherits:
BaseTag
  • Object
show all
Defined in:
lib/doc_template/tags/pd_tag.rb

Constant Summary collapse

CG_RE =
%r{/content_guides/(\d+)/}i.freeze
PDF_HTTP_RE =
%r{^https?://}i.freeze
PDF_HTTP_REPLACE_RE =
/^http:/i.freeze
PDF_RE =
/\.pdf$/i.freeze
TAG_NAME =
'pd'
TEMPLATES =
{
  default: 'pd.html.erb',
  gdoc: 'gdoc/pd.html.erb'
}.freeze
TYPE_CG =
'cg'
TYPE_PDF =
'pdf'
TYPE_PODCAST =
'podcast'
TYPE_YOUTUBE =
'youtube'

Constants inherited from BaseTag

BaseTag::SOFT_RETURN_RE, BaseTag::UNICODE_SPACES_RE

Instance Attribute Summary

Attributes inherited from BaseTag

#anchor, #content

Instance Method Summary collapse

Methods inherited from BaseTag

#before_tag, #check_tag_soft_return, #content_until_break, #content_until_materials, #ela2?, #ela6?, #gdoc?, #include_break?, #include_break_for?, #materials, parse, #parse_nested, #parse_template, #placeholder, #placeholder_id, #render, #replace_tag, #tag_data, tag_with_html_regexp, #template_name, #template_path, template_path_for

Instance Method Details

#parse(node, opts = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/doc_template/tags/pd_tag.rb', line 22

def parse(node, opts = {})
  @opts = opts
  @url, @title, @description, @start, @stop = opts[:value].split(';').map(&:strip)

  unless (embeded = fetch_data)
    node.remove
    return self
  end

  params = {
    description: description,
    resource: resource,
    start: start,
    stop: stop,
    subject: subject,
    title: title
  }.merge(embeded)
  @content = parse_template params, template_name(opts)
  replace_tag node
  self
end