C# Класс DotLiquid.Context

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ValueTypeTransformers Dictionary>

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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"]']

Описание методов

AddFilters() публичный Метод

public AddFilters ( ) : void
Результат void

AddFilters() публичный Метод

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
Результат void

ClearInstanceAssigns() публичный Метод

public ClearInstanceAssigns ( ) : void
Результат void

Context() публичный Метод

public Context ( ) : System
Результат System

Context() публичный Метод

public Context ( List environments, Hash outerScope, Hash registers, bool rethrowErrors ) : System
environments List
outerScope Hash
registers Hash
rethrowErrors bool
Результат System

GetValueTypeTransformer() публичный Метод

public GetValueTypeTransformer ( Type type ) : object>.Func
type System.Type
Результат object>.Func

HandleError() публичный Метод

public HandleError ( Exception ex ) : string
ex System.Exception
Результат string

HasKey() публичный Метод

public HasKey ( string key ) : bool
key string
Результат bool

Invoke() публичный Метод

public Invoke ( string method, List args ) : object
method string
args List
Результат object

Merge() публичный Метод

Merge a hash of variables in the current local scope
public Merge ( Hash newScopes ) : void
newScopes Hash
Результат void

Pop() публичный Метод

Pop from the stack. use Context#stack instead
public Pop ( ) : Hash
Результат Hash

Push() публичный Метод

Push new local scope on the stack. use Context#stack instead
public Push ( Hash newScope ) : void
newScope Hash
Результат void

Stack() публичный Метод

public Stack ( System.Action callback ) : void
callback System.Action
Результат void

Stack() публичный Метод

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
Результат void

this() публичный Метод

Only allow String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop
public this ( string key ) : object
key string
Результат object

Описание свойств

ValueTypeTransformers публичное свойство

public Dictionary> ValueTypeTransformers
Результат Dictionary>