Module: Locomotive::Steam::Liquid::Tags::Concerns::Path

Included in:
LinkTo, PathTo
Defined in:
lib/locomotive/steam/liquid/tags/concerns/path.rb

Constant Summary collapse

Syntax =
/(#{::Liquid::VariableSignature}+)(\s*,.+)?/o

Instance Method Summary collapse

Instance Method Details

#initialize(tag_name, markup, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/steam/liquid/tags/concerns/path.rb', line 10

def initialize(tag_name, markup, options)
  if markup =~ Syntax
    @handle, _options = $1, $2

    # FIXME: the with option needs a string with quotes.
    # this is a hack for sites which don't follow the new syntax.
    make_options_compatible_with_previous_version(_options)

    @raw_path_options = parse_options_from_string(_options)
  else
    self.wrong_syntax!
  end

  super
end

#render_path(context, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/locomotive/steam/liquid/tags/concerns/path.rb', line 26

def render_path(context, &block)
  set_vars_from_context(context)

  # return a drop or model?
  if page = self.retrieve_page_drop_from_handle
    # make sure we've got the page/content entry (if templatized)
    # in the right locale
    change_page_locale(locale, page) do
      path = build_fullpath(page)

      block_given? ? block.call(page, path) : path
    end
  else
    '' # no page found
  end
end