C# Class DotLiquid.Context

Exibir arquivo Open project: NewSpring/Rock Class Usage Examples

Public Properties

Property Type Description
ValueTypeTransformers Dictionary>

Public Methods

Method Description
AddFilters ( ) : void
AddFilters ( IEnumerable filters ) : void

Adds filters to this context. this does not register the filters with the main Template object. see Template.register_filter for that

ClearInstanceAssigns ( ) : void
Context ( ) : System
Context ( List environments, Hash outerScope, Hash registers, bool rethrowErrors ) : System
GetValueTypeTransformer ( Type type ) : object>.Func
HandleError ( Exception ex ) : string
HasKey ( string key ) : bool
Invoke ( string method, List args ) : object
Merge ( Hash newScopes ) : void

Merge a hash of variables in the current local scope

Pop ( ) : Hash

Pop from the stack. use Context#stack instead

Push ( Hash newScope ) : void

Push new local scope on the stack. use Context#stack instead

Stack ( System.Action callback ) : void
Stack ( Hash newScope, System.Action callback ) : void

pushes a new local scope on the stack, pops it at the end of the block Example: context.stack do context['var'] = 'hi' end context['var] #=> nil

this ( string key ) : object

Only allow String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop

Private Methods

Method Description
FindVariable ( string key ) : object

Fetches an object starting at the local scope and then moving up the hierarchy

IsHashOrArrayLikeObject ( object obj, object part ) : bool
Liquidize ( object obj ) : object
LookupAndEvaluate ( object obj, object key ) : object
Resolve ( string key ) : object

Look up variable, either resolve directly after considering the name. We can directly handle Strings, digits, floats and booleans (true,false). If no match is made we lookup the variable in the current scope and later move up to the parent blocks to see if we can resolve the variable somewhere up the tree. Some special keywords return symbols. Those symbols are to be called on the rhs object in expressions Example: products == empty #=> products.empty?

SquashInstanceAssignsWithEnvironments ( ) : void
Variable ( string markup ) : object

Resolves namespaced queries gracefully. Example @context['hash'] = {"name" => 'tobi'} assert_equal 'tobi', @context['hash.name'] assert_equal 'tobi', @context['hash["name"]']

Method Details

AddFilters() public method

public AddFilters ( ) : void
return void

AddFilters() public method

Adds filters to this context. this does not register the filters with the main Template object. see Template.register_filter for that
public AddFilters ( IEnumerable filters ) : void
filters IEnumerable
return void

ClearInstanceAssigns() public method

public ClearInstanceAssigns ( ) : void
return void

Context() public method

public Context ( ) : System
return System

Context() public method

public Context ( List environments, Hash outerScope, Hash registers, bool rethrowErrors ) : System
environments List
outerScope Hash
registers Hash
rethrowErrors bool
return System

GetValueTypeTransformer() public method

public GetValueTypeTransformer ( Type type ) : object>.Func
type System.Type
return object>.Func

HandleError() public method

public HandleError ( Exception ex ) : string
ex System.Exception
return string

HasKey() public method

public HasKey ( string key ) : bool
key string
return bool

Invoke() public method

public Invoke ( string method, List args ) : object
method string
args List
return object

Merge() public method

Merge a hash of variables in the current local scope
public Merge ( Hash newScopes ) : void
newScopes Hash
return void

Pop() public method

Pop from the stack. use Context#stack instead
public Pop ( ) : Hash
return Hash

Push() public method

Push new local scope on the stack. use Context#stack instead
public Push ( Hash newScope ) : void
newScope Hash
return void

Stack() public method

public Stack ( System.Action callback ) : void
callback System.Action
return void

Stack() public method

pushes a new local scope on the stack, pops it at the end of the block Example: context.stack do context['var'] = 'hi' end context['var] #=> nil
public Stack ( Hash newScope, System.Action callback ) : void
newScope Hash
callback System.Action
return void

this() public method

Only allow String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop
public this ( string key ) : object
key string
return object

Property Details

ValueTypeTransformers public_oe property

public Dictionary> ValueTypeTransformers
return Dictionary>