Dotiac::DTL::Value - Saves Dotiac::DTL-value.
my $v=Dajango::Template::Value->safe($data); if ($v->array) { } if ($v->number) { } print $v->content();
Stores a value in an object, for use in filters. This marks the value safe for output or needs escaping.
Creates a new Dajango::Template::Value with the contents VALUE. It will be marked as safe for output if SAFE is set to true.
$value=Dajango::Template::Value->new($data,!$autoescape);
Creates a new Dajango::Template::Value with the contents VALUE and marks it as safe for output.
$value=Dajango::Template::Value->safe($data);
Creates a new Dajango::Template::Value with the contents VALUE and marks it for escaping during output.
$value=Dajango::Template::Value->escape($data);
These can be called on the created Dajango::Template::Value objects:
Returns true if this Dajango::Template::Value is safe for output
if ($value->safe) { ... }
Marks this Dajango::Template::Value as safe without changing its contents.
if ($time > 1) { #Or something $value->safe(1); }
Returns true if this Dajango::Template::Value needs escaping for output
if ($value->escape) { ... }
Marks this Dajango::Template::Value as unsafe without changing its contents.
if ($time < 1) { #Or something $value->escape(1); }
Returns true if the contained value is an array.
if ($value->array) { foreach (@{$value->content}) { ... } }
Returns true if the contained value is a hash.
if ($value->hash) { foreach (keys %{$value->content}) { ... } }
Returns true if the contained value is an object.
if ($value->object) { die "Can't work with blessed variables"; }
Returns true if the contained value is a number.
if ($value->number) { $value->set($value->content*20); }
Returns true if the contained value is not defined.
if ($value->undef) { return Dotiac::DTL::Value->safe("Error"); }
Returns true if the contained value is defined.
if ($value->defined) { return $value; } return Dotiac::DTL::Value->safe("No Text found");
Returns true if the contained value is defined and not a reference.
if ($value->scalar) { return Dotiac::DTL::Value->safe(lc $value->content); }
Returns a true Value if the object is true or filled (for array and hashrefs) and "" otherwise.
It will return the size of the referenced container of an arrayref or hashref.
It will also try to run the count() method of an object, if available.
Should be about the same result as Dotiac::DTL::Core's Dotiac::DTL::Conditional($var->content);
Returns the contained value.
print $value->content;
print $value->get;
Returns the contained value in a readable way and escapes the output if it's marked as unsafe.
Calls the string() method on a contained object that provides one.
print $value->string;
Same as string()
Returns the contained value in a readable way, but don't escapes, even if the content is unsafe.
Calls the string() or the repr() method on a contained object that provides one of them.
This is useful if you need to escape the value yourself.
print CGI::escape($value->repr()); #URLencode
Same as repr(), but calls the repr() method on a contained object before it calls string();
Same as string(), but returns undef if the content is not defined.
Changes the contained value without changing the safe/escape status.
If you want to apply some functions on the value, regardless of content or escape/safe status, use set() and repr():
$value->set(uc $value->repr()); #Applies uc() on the content of $value, but doesn't change the output mode.
Returns itself, so you can write (in a filter):
return $value->set("Foo") if $foo;
Rekursive generator for pyrepr.
Rekursive generator for repr.
Rekursive generator for string.
If you find a bug, please report it.
http://www.djangoproject.com, Dotiac::DTL
Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.
Marc-Sebastian Lucksch
perl@marc-s.de
To install Dotiac::DTL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dotiac::DTL
CPAN shell
perl -MCPAN -e shell install Dotiac::DTL
For more information on module installation, please visit the detailed CPAN module installation guide.