module Snippr

Snippr::I18n

Provides support for I18n snippr files.

Snippr::LinkHelper

This module can be included to get functionality to adjust links.

Snippr::MetaData

Handles Snippr's YAML Front Matter inspired by Jekyll. Useful for passing meta information about a Snip to the app.

Snippr::Normalizer

Provides methods to normalize snippr path elements.

Snippr::Normalizer::DeRester

“Redirects” REST path elements that are accessed via POST (create, update destroy) with their corresponding GET elements (new, edit, show) so that when eg create is rendered due to an error in the action, it just looks exactly like the new page it was issued from.

Snippr::Path

Provides methods for dealing with the path to snippr files.

Snippr::Processor

Provides methods to process snippr content.

Snippr::Processor::Dynamics

Replaces {placeholder} placeholders in the content with values taken from the given opts.

Snippr::Processor::Functions

Processes several functions in {command:options} syntax.

Snippr::Processor::Links

Adjusts URLs in links.

Snippr::Processor::Wikilinks

Replaces links in [url|title] syntax with real links.

Snippr

File based content management

A snippr file is a piece of HTML or raw text to be included in a website. They are plain text files stored on the file system. Snippr files end with “.snip” and are read from the Snippr path.

Snippr::ViewHelper

This module is automatically included into ActionView::Base when using the Snippr component with Rails. It provides a snippr helper method for loading snippr files.

%h1 Topup successful
.topup.info
  = snippr :topup, :success
%h1 Conditional output
- snippr :topup, :conditional_snippr do |snip|
  #cond= snip

Attributes

logger[W]

Sets the logger to use.

Public Instance Methods

adjust_urls_except() click to toggle source

Returns the regular expressions used to determine which urls to exclude from adjustment.

# File lib/snippr/snippr.rb, line 40
def adjust_urls_except
  Links.adjust_urls_except
end
adjust_urls_except=(adjust_urls_except) click to toggle source

Sets the regular expressions used to determine which urls to exclude from adjustment.

# File lib/snippr/snippr.rb, line 45
def adjust_urls_except=(adjust_urls_except)
  Links.adjust_urls_except = adjust_urls_except
end
i18n=(enabled) click to toggle source

Sets whether to use I18n snippr files.

# File lib/snippr/snippr.rb, line 35
def i18n=(enabled)
  I18n.enabled = enabled
end
i18n?() click to toggle source

Returns whether to use I18n snippr files.

# File lib/snippr/snippr.rb, line 30
def i18n?
  I18n.enabled?
end
list(*args) click to toggle source

Lists all snips inside a snippr directory specified by path parts.

# File lib/snippr/snippr.rb, line 64
def list(*args)
  Path.list(*args)
end
load(*args) click to toggle source

Expects the name of a snippr file. Also accepts a Hash of placeholders to be replaced with dynamic values.

# File lib/snippr/snippr.rb, line 59
def load(*args)
  Snip.new(*args)
end
logger() click to toggle source

Returns the logger. Uses the Rails logger when available or falls back to a custom logger.

# File lib/snippr/snippr.rb, line 53
def logger
  @logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
end
path() click to toggle source

Returns the path to the snippr files (from JVM properties if available).

# File lib/snippr/snippr.rb, line 12
def path
  Path.path
end
path=(path) click to toggle source

Sets the path to the snippr files.

# File lib/snippr/snippr.rb, line 17
def path=(path)
  Path.path = path
end
tardis_enabled() click to toggle source
# File lib/snippr/snippr.rb, line 25
def tardis_enabled
  Tardis.enabled
end
tardis_enabled=(bool_or_block) click to toggle source
# File lib/snippr/snippr.rb, line 21
def tardis_enabled=(bool_or_block)
  Tardis.enabled = bool_or_block
end