# -*- coding: utf-8 -*-
YATT_CONFIG[
special_entities[
- HTML
]
]

TITLE: &yatt:dump();
IN:
 <!yatt:args x=list>
 &yatt:HTML(:dump(:x));
PARAM[
[
- foo
- bar
]
]
OUT:
 ['foo','bar']


TITLE: &HTML(:var);
IN:
 <!yatt:args x=html>
 &HTML(:x);
PARAM[
- <h2>foo</h2>
]
OUT:
 <h2>foo</h2>


TITLE: &yatt:template();
IN:
 <!yatt:config usage="For template entity">
 &yatt:template(){usage};.
OUT:
 For template entity.

TITLE: &yatt:concat();
IN:
 <!yatt:args x y z>
 &yatt:concat(:x,:y,foo,:z);
PARAM[
- A
- B
- C
]
OUT:
 ABfooC


TITLE: &yatt:join(); and &yatt:lexpand();
IN:
 <!yatt:args x=list>
 &yatt:join(-,:lexpand(:x));
PARAM[
[
- A
- B
-
- C
]
]
OUT:
 A-B-C


TITLE: :lexpand(:var:path())
IN:
 <!yatt:args x=value>
 (&yatt:join(-,:lexpand(:x{foo}));)
PARAM[
{
foo[
- x
- y
- z
]
}
]
OUT:
 (x-y-z)

TITLE: &yatt:format(fmt,values);
IN:
 <!yatt:args fmt x=list>
 &yatt:format(:fmt,:lexpand(:x));
PARAM[
- foo%2$sbar%1$sbaz
[
- X
- Y
]
]
OUT:
 fooYbarXbaz


TITLE: &yatt:breakpoint();
IN:
 A &yatt:breakpoint(); B
OUT:
 A  B


TITLE: entity in pi
IN:
 <!yatt:args x=list>
 <?perl= &yatt:join(-,:lexpand(:x));  ?>
PARAM[
[
- A
- B
-
- C
]
]
OUT:
 A-B-C


TITLE: Nested hash &yatt:foo:bar:baz;
IN:
 <!yatt:args foo=value>
 &yatt:foo:bar:baz;
PARAM[
{
bar{
baz: hoehoe
}
}
]
OUT:
 hoehoe


TITLE: render(name,arg...) h2
IN:
 <!yatt:args wname x y>
 header
 &yatt:render(t_$wname,:x,:y);
 footer
 
 <!yatt:widget t_h2 a b>
 <h2>&yatt:a;</h2>
 &yatt:b;
 
 <!yatt:widget t_ol a list=list>
 <ol class="&yatt:a;">
  <yatt:foreach my=row list>
  <li>&yatt:row;</li>
  </yatt:foreach>
 </ol>
PARAM[
- h2
- title
- body
]
OUT:
 header
 <h2>title</h2>
 body
 
 footer

TITLE: render(name,arg...) ol
PARAM[
- ol
- ordered
[
- apple
- lemon
- orange
]
]
OUT:
 header
 <ol class="ordered">
  <li>apple</li>
  <li>lemon</li>
  <li>orange</li>
 
 </ol>
 
 footer


TITLE: render([foo,bar],args) => foo_bar
IN:
 <!yatt:args ls=list>
 &yatt:render(:ls,X);
 
 <!yatt:widget foo_bar x>
 foo &yatt:x; bar
 <!yatt:widget foo_ x>
 fooonly x=&yatt:x;
 <!yatt:widget _bar x>
 baronly x=&yatt:x;
PARAM[
[
- foo
- bar
]
]
OUT:
 foo X bar
 

TITLE: render([=undef,bar],args);
PARAM[
[
= #null
- bar
]
]
OUT:
 baronly x=X
 

TITLE: render([foo,=undef],args);
PARAM[
[
- foo
= #null
]
]
OUT:
 fooonly x=X
 

TITLE: datetime
REQUIRE: DateTime
IN:
 <!yatt:args>
 <yatt:my dt:value="&yatt:datetime(new,year,1964,month,10,day,10);"/>
 &yatt:dt:year();
 &yatt:dt:month();
 &yatt:dt:day();
OUT:
 1964
 10
 10

TITLE: url_encode
IN:
 <!yatt:args url>
 &yatt:url_encode(:url);
PARAM[
- http://0:5000/foo?x=y&z=w;p=q
]
OUT:
 http://0:5000/foo%3Fx%3Dy%26z%3Dw%3Bp%3Dq


TITLE: alternative
IN:
 ja->&yatt:alternative(ja,[en,ja]);
 en->&yatt:alternative(en,[en,ja]);
 x->&yatt:alternative(x,[en,ja]);
OUT:
 ja->en
 en->ja
 x->en


TITLE: append_params
IN:
 <!yatt:args url list=list>
 &yatt:append_params(:url,:lexpand(:list));
PARAM[
- http://0:5000/foo
[
[
- nx
- /bar?a=b
]
]
]
OUT:
 http://0:5000/foo?nx=%2Fbar%3Fa%3Db


TITLE: append_params(more params)
PARAM[
- http://0:5000/bar?x=y
[
[
aaa: bbb
]
[
ccc: ddd
]
[
aaa: fff
]
]
]
OUT:
 http://0:5000/bar?x=y&amp;aaa=bbb&amp;ccc=ddd&amp;aaa=fff


TITLE: append_params(replace same param)
PARAM[
- http://0:5000/baz?x=X
[
[
x: Y
]
]
]
OUT:
 http://0:5000/baz?x=Y


TITLE: query_string()
CON_CLASS: YATT::Lite::WebMVC0::Connection
PARAM[
x: foo
y: bar
]
IN:
 &yatt:query_string;
OUT:
 x=foo;y=bar


TITLE: query_string(separator,(&))
CON_CLASS: YATT::Lite::WebMVC0::Connection
PARAM[
x: FOO
y: BAR
]
TODO: It's too late to change. You need :HTML()
IN:
 &yatt:query_string(separator,(&));
OUT:
 x=FOO&y=BAR


TITLE: :HTML(query_string(separator,(&)))
CON_CLASS: YATT::Lite::WebMVC0::Connection
PARAM[
x: aaa
y: bbb
]
IN:
 &yatt:HTML(:query_string(separator,(&)));
OUT:
 x=aaa&y=bbb


TITLE: query_string(merge,HASH)
CON_CLASS: YATT::Lite::WebMVC0::Connection
PARAM[
x: foo
y: bar
]
IN:
 &yatt:query_string(merge,{y,BAZ});
OUT:
 x=foo;y=BAZ


TITLE: query_string(of,HASH,delete,[a,b])
IN:
 <yatt:my dict:value="{a => 'xxx', b => 'yyy', x => 'foo'}"/>
 &yatt:query_string(of,:dict,delete,[a,b]);
 &yatt:dict;
OUT:
 x=foo
 {
   'a' => 'xxx',
   'b' => 'yyy',
   'x' => 'foo'
 }
 

TITLE: :default(,,none) => none
PARAM[
]
IN:
 <!yatt:args x y z="?none">
 &yatt:default(:x,:y,:z);
OUT:
 none


TITLE: :default(,0,none) => 0
PARAM[
- 
- 0
]
OUT:
 0

TITLE: :default(ok,0,none) => ok
PARAM[
- ok
- 0
]
OUT:
 ok


TITLE: :coalesce(=undef,=undef,none) => none
PARAM[
]
IN:
 <!yatt:args x y z="?none">
 &yatt:coalesce(:x,:y,:z);
OUT:
 none


TITLE: :coalesce(=undef,,none) => (empty)
PARAM[
- 
- 
]
OUT:
 

TITLE: :coalesce(ok,0,none) => ok
PARAM[
- ok
- 0
]
OUT:
 ok


TITLE: Direct entity definitions in yatt
IN:
 <h2>&yatt:add(3,8);</h2>
 &yatt:mul(3,8);
 <!yatt:entity add x y>
 $x + $y
 <!yatt:entity mul x y>
 $x * $y
OUT:
 <h2>11</h2>
 24


TITLE: Direct entity with $CON reference
CON_CLASS: YATT::Lite::WebMVC0::Connection
IN:
 <h2>&yatt:foo();</h2>
 
 <!yatt:entity foo>
 $CON->param('.x') * $CON->param('.y')
PARAM{
.x: 3
.y: 8
}
OUT:
 <h2>24</h2>



TITLE: :val()
IN:
 &yatt:val(1);
 &yatt:val();
 &yatt:val(foo,bar);
 &yatt:val(:val([]));
 &yatt:val(:val(:val({})));
OUT:
 1
 
 foo
 []
 
 {}
 
