NAME
Dotiac::DTL::Parser - The default Django/Dotiac parser
SYNOPSIS
require Dotiac::DTL;
$t=Dotiac::DTL->new("file.html")
$t->print();
Static methods
new(FILE) or new(FILE,COMPILE)
Creates a new empty Dotiac::DTL::Parser, used by Dotiac::DTL->new().
Methods
parse(TEMPLATEREF,POSITIONREF, [FOUNDREF, List,of,endtags,to,look,for])
Parses the string referenced in TEMPLATEREF starting at the position referenced in POSITIONREF.
Returns the parsed templatedata if either one of the endtags is found (and sets FOUNDREF to the endtag) or the end of the string is reached.
This is used by tags to look for their endtag. For example the ifequal tag:
sub new {
my $class=shift;
my $self={p=>shift()}; #Text that came before the tag.
my $data=shift; #Content of the tag other than the name.
my $obj=shift;
my $data=shift; #Templatedataref
my $pos=shift; #and positionref from the parse() calling this tags new().
my $found=""; #Empty found
$self->{true}=$obj->parse($data,$pos,\$found,"else","endifequal"); #Search for either "else" or "endifequal" and set it to $found.
if ($found eq "else") {
$self->{false}=$obj->parse($data,$pos,\$found,"endifequal"); #If "else" was found, search for "endifequal"
}
($self->{var1},$self->{var2},undef)=Dotiac::DTL::get_variables($data);
bless $self,$class;
return $self;
}
#....
Note
Dotiac::DTL::Reduced doesn't support this, so it doesn't have to load all the tags or the parser.
unparsed(TEMPLATEREF,POSITIONREF, [FOUNDREF, STARTTAG, List,of,endtags,to,look,for])
Parses the string referenced in TEMPLATEREF starting at the position referenced in POSITIONREF.
Returns the unparsed templatedata if either one of the endtags is found (and sets FOUNDREF to the endtag) or the end of the string is reached.
Skips STARTTAG occurences and searches for additional endtags
This is used by tags to look for their endtag. For example an unparsed tag:
sub new {
my $class=shift;
my $self={p=>shift()}; #Text that came before the tag.
my $data=shift; #Content of the tag other than the name.
my $obj=shift;
my $data=shift; #Templatedataref
my $pos=shift; #and positionref from the parse() calling this tags new().
my $found=""; #Empty found
$self->{content}=$obj->unparsed($data,$pos,\$found,"unparsed","endunparsed");
bless $self,$class;
return $self;
}
#....
Note
There is no internal tag for now that needs this. But you might find some addons.
I planned this for a addon like Calypso DTL's {% ajax %} tag, that throws the unparsed template at DojoxDTL to render it in the browser.
Dotiac::DTL::Reduced doesn't support this either.
SEE ALSO
http://www.djangoproject.com, Dotiac::DTL
BUGS
If you find a bug, please report it.
LEGAL
Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.
AUTHOR
Marc-Sebastian Lucksch
perl@marc-s.de