Tripletail
view release on metacpan or search on metacpan
lib/Tripletail/Template/Node.pm view on Meta::CPAN
# -----------------------------------------------------------------------------
# Tripletail::Template::Node - Templateãã¼ããªãã¸ã§ã¯ã
# -----------------------------------------------------------------------------
package Tripletail::Template::Node;
use strict;
use warnings;
use Tripletail;
#use Smart::Comments;
my @_SPLIT_CACHE;
1;
# ãã³ãã¬ã¼ãããã¼ãæ¯ã«åå²
#
# <html>
# aaa<&FOO>bbb
# <!mark:bar>
# <!copy:Bar>
# </html>
#
# $this->{tmplvec} = []; # Template Vector
# ==> [0] = "<html>\n aaa"
# [1] = ['tag', 'foo', \"tag:foo"]
# [2] = "bbb\n "
# [3] = ['mark', 'bar', \"node:bar"]
# [4] = "\n "
# [5] = ['copy', 'baz', \"node:baz"]
# [6] = "\n </html>"
#
# $this->[tmpltags] = ['foo'];
#
# $this->{tmplback} = []; # tmplvec ã®ã³ãã¼
#
# æ¿å
¥ã¿ã°ã<!mark>, <!copy> ã¸ã®æ¿å
¥ã¯ã{ã¿ã°å => å¤} ã®ããã·ã¥ã¸å¤ãè¨å®ããäºã§è¡ãã
# ãªã»ããæã«ã¯ãã®ããã·ã¥ã®å
容ã空ã«ããã¨åæã« tmplvec ãããã¯ã¢ããããæ¸ãæ»ãã
#
# $this->{valmap} = {}; # Value Map
# ==> [tag:foo] = "FOOã«å
¥ããããã¹ã"
# [node:bar] = "ãã¼ã bar ã add ããæã®å
容"
#
# flush æã«ã¯ãã³ãã¬ã¼ãã®å
é ããå°ããã¤åã£ã¦è¡ãäºã«ãªãçºã
# tmplvec ã®å
å®¹ã¯æµ
ãå¤åããã(ã¤ã¾ãé
åã¯å¤åãã¦ãé
åã®è¦ç´ ã¾ã§ã¯
# å¤åããªãã)
sub _new {
my $class = shift;
my $parent = shift; # Tripletail::Template::Node ã¾ã㯠undef (rootã®å ´å)
my $name = shift; # <!mark>ã®ååãrootãªãundef
my $html = shift; # template html
my $allow_unexpanded_tags = shift; # allow_unexpanded_tags
my $this = bless {} => $class;
$this->_reset;
$this->{parent} = $parent;
$this->{name} = defined($name) ? lc $name : undef; # rootã®å ´åã¯ä½¿ããããã¨ã¯ãªã.
$this->{allow_unexpanded_tags} = $allow_unexpanded_tags || 'false';
if(defined $html) {
$this->_setTemplate($html);
}
$this;
}
sub _reset {
my $this = shift;
# 以ä¸ã¯ã«ã¼ãã«ã®ã¿åå¨ãã
$this->{is_xhtml} = undef;
# ã½ã¼ã¹åé åç
§
$this->{tmplvec} = [];
$this->{tmplback} = [];
$this->{valmap} = {};
# ãã¼ã -- {name => Tripletail::Template::Node}
$this->{node} = {};
# ã¿ã°å±æ§
$this->{attr} = {};
# trim
$this->{trimed} = {
first => undef,
last => undef,
leadings => undef,
followings => undef,
leadings_join => undef,
followings_join => undef,
};
$this;
}
sub isRoot {
my $this = shift;
!defined($this->{parent});
}
sub isXHTML {
my $this = shift;
$this->isRoot ? $this->{is_xhtml} : $this->{parent}->isXHTML;
}
sub _setTemplate {
my $this = shift;
my $str = shift;
$this->_reset;
( run in 1.073 second using v1.01-cache-2.11-cpan-97f6503c9c8 )