Module: Yuzu::Filters

Includes:
Core, Registrar
Included in:
Core::WebsiteFile, Generators
Defined in:
lib/yuzu/filters/base.rb,
lib/yuzu/filters/images.rb,
lib/yuzu/filters/catalog.rb,
lib/yuzu/filters/sidebar.rb,
lib/yuzu/filters/linkroot.rb,
lib/yuzu/filters/template.rb,
lib/yuzu/filters/extension.rb,
lib/yuzu/filters/post_date.rb,
lib/yuzu/filters/categories.rb,
lib/yuzu/filters/post_title.rb,
lib/yuzu/filters/currentpath.rb,
lib/yuzu/filters/description.rb,
lib/yuzu/filters/post_title_removed.rb

Defined Under Namespace

Classes: Catalog, CatalogFilter, CategoriesFilter, Category, CurrentpathFilter, DescriptionFilter, ExtensionFilter, Filter, ImagesFilter, LinkrootFilter, PostDateFilter, PostTitleFilter, PostTitleRemovedFilter, SidebarFilter, TemplateFilter

Constant Summary

Constants included from Core

Core::BOLD, Core::ENDC, Core::WHITE

Class Method Summary collapse

Methods included from Core

get_paginated_path

Class Method Details

.catalog_for(website_file, match_string) ⇒ Catalog

Create a Catalog instance for a given match

Parameters:

  • website_file (WebsiteFile)

    The file in which the catalog is being rendered.

  • match_string (String)

    The match given by the filter, e.g. “page:1, per_row:3, …”

Returns:

  • (Catalog)

    The catalog object responsible for rendering the pages specified.



38
39
40
41
# File 'lib/yuzu/filters/catalog.rb', line 38

def catalog_for(website_file, match_string)
  kwds = Yuzu::Filters.get_kwds(match_string)
  Catalog.new(kwds, website_file, match_string)
end

.get_kwds(match_string) ⇒ Hash

Returns a Hash of the keyword arguments contained in the inner match string of the tag:

INSERTCATALOG(page: 1, count:10)

yields

{:page => 1, :count => 10}

Parameters:

  • match_string (String)

    The text inside the tag match.

Returns:

  • (Hash)

    The key to value pairs.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/yuzu/filters/catalog.rb', line 54

def get_kwds(match_string)
  pairs = match_string.split(",").collect {|pair| pair.strip}

  kwds = {}
  pairs.each do |pair|
    key, val = pair.split(":").collect {|el| el.strip}
    kwds[key.to_sym] = val
  end

  kwds
end