Sha256: c3abf11b4f8a52830831bf04f683c0f491a89593e0d06439e8866b7c5182c71a
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require "active_support/concern" require "active_support/hash_with_indifferent_access" module Machined module Helpers module LocalsHelpers extend ActiveSupport::Concern # Adds psuedo local variables from the given hash, where # the key is the name of the variable. This is provided so # processors can add local variables without having access # to the next processor or template. def locals=(locals) if locals.nil? @locals = nil else self.locals.merge! locals end end # Returns the locals hash. It's actually an instance # of `ActiveSupport::HashWithIndifferentAccess`, so strings # and symbols can be used interchangeably. def locals @locals ||= ActiveSupport::HashWithIndifferentAccess.new end # Returns true if the given +name+ has been set as a local # variable. def has_local?(name) locals.key? name end # Returns the default layout, unless overridden by # the YAML front matter. def layout if has_local?(:layout) locals[:layout] else machined.config.layout end end def method_missing(method, *args, &block) # :nodoc: if args.empty? && has_local?(method) locals[method] else super end end def respond_to?(method) # :nodoc: super or has_local?(method) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
machined-0.1.0 | lib/machined/helpers/locals_helpers.rb |