class Liquid::Context
- Liquid::Context
- Reference
- Object
Defined in:
liquid/context.crliquid/json.cr
Constructors
-
.new(strict : Bool)
DEPRECATED Use
initialize(ErrorMode)
instead. - .new(error_mode : Liquid::Context::ErrorMode = :lax, data : Hash(String, Liquid::Any) = Hash(String, Any).new)
Instance Method Summary
-
#[](var : String) : Any
Alias for
#get
- #[]=(var, value : Any) : Any
- #[]=(var, value : Any::Type) : Any
-
#[]=(var : String, val : Array(String))
DEPRECATED Use
#set
instead. -
#[]=(var : String, val : Hash(String, String))
DEPRECATED Use
#set
instead. -
#[]?(var : String) : Any | Nil
Fetch a variable from context and return nil if the variable isn't found.
- #error_mode : ErrorMode
- #error_mode=(error_mode : ErrorMode)
-
#errors : Array(Liquid::LiquidException)
List of errors found when rendering using this context.
- #get(var, strict : Bool)
-
#get(var : String) : Any
Fetch a variable from context, add
UndefinedVariable
error if the variable isn't found and behave according the error mode. - #lax?(*args, **options)
- #lax?(*args, **options, &)
- #set(var : String, value : Any) : Any
- #set(var : String, value : Any::Type) : Any
-
#set(var : String, json : JSON::Any) : Nil
Set the contents of a JSON::Any to the context.
-
#strict : Bool
DEPRECATED Use
#error_mode
instead. -
#strict=(value : Bool) : Bool
DEPRECATED Use
#error_mode=
instead. - #strict?(*args, **options)
- #strict?(*args, **options, &)
-
#to_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
- #warn?(*args, **options)
- #warn?(*args, **options, &)
Constructor Detail
Instance Method Detail
Fetch a variable from context and return nil if the variable isn't found.
This doesn't trigger any exceptions or store any errors if the variable doesn't exists.
List of errors found when rendering using this context.
Fetch a variable from context, add UndefinedVariable
error if the variable isn't found and behave according the
error mode.
Set the contents of a JSON::Any to the context.
NOTE You need to require "liquid/json" to use this method.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>