Module: Noumenon::Template::CoreTags::Filters

Defined in:
lib/noumenon/template/core_tags.rb

Overview

The core set of filters provided by Noumenon for use in templates.

Instance Method Summary collapse

Instance Method Details

#assign_to(input, variable) ⇒ Object

Assigns the data piped in to the named variable.

Examples:

{{ "Jon" | assign_to: "name" }}
{{ name }}


20
21
22
23
# File 'lib/noumenon/template/core_tags.rb', line 20

def assign_to(input, variable)
  @context.scopes.last[variable] = input
  ''
end

#item_at_path(input) ⇒ Object

Loads the content item at the path provided and passes it on.

If nothing was found then nothing will be returned, allowing the presence of some content to be checked before trying to use it.

Examples:

{{ "/includes/site_details" | item_at_path | assign_to: "site" }}
{% if site %}
  <h1>{{ site.title }}</h1>
  <p>Written by {{ site.author }}</p>
{% end %}


38
39
40
41
# File 'lib/noumenon/template/core_tags.rb', line 38

def item_at_path(input)
  item = Noumenon.content_repository.get(input)
  item ? item.stringify_keys : nil
end

#textilize(input) ⇒ Object

Formats the provided text using Textile.

Examples:

{{ "h1. Hello, world" | textilize }}
<!-- <h1>Hello, world</h1> -->


50
51
52
# File 'lib/noumenon/template/core_tags.rb', line 50

def textilize(input)
  RedCloth.new(input).to_html
end