Class Mustache::Context
In: lib/mustache/context.rb
Parent: Object

A Context represents the context which a Mustache template is executed within. All Mustache tags reference keys in the Context.

Methods

[]   []=   escapeHTML   fetch   find   has_key?   mustache_in_stack   new   partial   pop   push   update  

Public Class methods

Expect to be passed an instance of `Mustache`.

Public Instance methods

Alias for `fetch`.

Can be used to add a value to the context in a hash-like way.

context[:name] = "Chris"

Allows customization of how Mustache escapes things.

Returns a String.

Similar to Hash#fetch, finds a value by `name` in the context‘s stack. You may specify the default return value by passing a second parameter.

If no second parameter is passed (or raise_on_context_miss is set to true), will raise a ContextMiss exception on miss.

Finds a key in an object, using whatever method is most appropriate. If the object is a hash, does a simple hash lookup. If it‘s an object that responds to the key as a method call, invokes that method. You get the idea.

    obj - The object to perform the lookup on.
    key - The key whose value you want.

default - An optional default value, to return if the

          key is not found.

Returns the value of key in obj if it is found and default otherwise.

Do we know about a particular key? In other words, will calling `context[key]` give us a result that was set. Basically.

Find the first Mustache in the stack. If we‘re being rendered inside a Mustache object as a context, we‘ll use that one.

A {{>partial}} tag translates into a call to the context‘s `partial` method, which would be this sucker right here.

If the Mustache view handling the rendering (e.g. the view representing your profile page or some other template) responds to `partial`, we call it and render the result.

Removes the most recently added object from the context‘s internal stack.

Returns the Context.

Adds a new object to the context‘s internal stack.

Returns the Context.

update(new)

Alias for push

[Validate]