##
##
##

###

- name:  basic
  contexts:
   "list":
      title:      Users List
      items:
        - name:   Robert
          email:  bob@example.com
          gender: m
        - name:   Margalette
          email:  meg@example.com
          gender: w
        - name:   William
          email:  bill@example.com
          gender: m
   "show":
      title:      Show User
      item:
        name:     Robert
        email:    bob@example.com
        gender:   m
   "create":
      title:      Create User
      params:
        name:
        email:
        gender:
   "edit":
      title:      Edit User
      params:
        name:     Robert
        email:    bob@example.com
        gender:   m

  templates:
  
    - filename: user_layout.xxhtml
      content*:
       "python": |
          <html>
            <body>
              <h1>${title}</h1>
              <div id="sidemenu">
          <?py include(':sidemenu') ?>
              </div>
              <div id="maincontent">
          #{_content}
              </div>
              <div id="footer">
          #{include('footer.html', False)}
              </div>
            </body>
          </html>
       "ruby": |
          <html>
            <body>
              <h1>${@title}</h1>
              <div id="sidemenu">
          <?rb import :sidemenu ?>
              </div>
              <div id="maincontent">
          #{@_content}
              </div>
              <div id="footer">
          #{import 'footer.html', false}
              </div>
            </body>
          </html>
       "perl": |
          <html>
            <body>
              <h1>[=$title=]</h1>
              <div id="sidemenu">
          <?pl include(':sidemenu') ?>
              </div>
              <div id="maincontent">
          [==$_content=]
              </div>
              <div id="footer">
          <?pl include('footer.html') ?>

              </div>
            </body>
          </html>
       "js": |
          <html>
            <body>
              <h1>${title}</h1>
              <div id="sidemenu">
          <?js include(':sidemenu') ?>
              </div>
              <div id="maincontent">
          #{$_content}
              </div>
              <div id="footer">
          <?js include('footer.html') ?>

              </div>
            </body>
          </html>
  
    - filename: user_list.xxhtml
      content*:
       "python": |
          <ul>
          <?py for item in items: ?>
            <li>${item['name']}
                (${item['email']})</li>
          <?py #end ?>
          </ul>
       "ruby": |
          <ul>
          <?rb for item in @items ?>
            <li>${item['name']}
                (${item['email']})</li>
          <?rb end ?>
          </ul>
       "perl": |
          <ul>
          <?pl for my $item (@$items) { ?>
            <li>[=$item->{name}=]
                ([=$item->{email}=])</li>
          <?pl } ?>
          </ul>
       "js": |
          <ul>
          <?js for (var i=0; i<items.length; i++) { ?>
            <li>${items[i].name}
                (${item[i].email})</li>
          <?js } ?>
          </ul>
  
    - filename: user_show.xxhtml
      content*:
       "python": |
          <p>
            Name: ${item['name']}<br />
            Email: ${item['email']}
          </p>
       "ruby": |
          <p>
            Name: ${@item['name']}<br />
            Email: ${@item['email']}
          </p>
       "perl": |
          <p>
            Name: [=$item->{name}=]<br />
            Email: [=$item->{email}=]
          </p>
       "js": |
          <p>
            Name: ${item.name}<br />
            Email: ${item.email}
          </p>
  
    - filename: user_form.xxhtml
      content*:
       "python": |
          <p>
            Name: <input type="input" name="name" value="${params['name']}" />
          </p>
          <p>
            Email: <input type="input" name="email" value="${params['email']}" />
          </p>
       "ruby": |
          <p>
            Name: <input type="input" name="name" value="${@params['name']}" />
          </p>
          <p>
            Email: <input type="input" name="email" value="${@params['email']}" />
          </p>
       "perl": |
          <p>
            Name: <input type="input" name="name" value="[=$params->{name}=]" />
          </p>
          <p>
            Email: <input type="input" name="email" value="[=$params->{email}=]" />
          </p>
       "js": |
          <p>
            Name: <input type="input" name="name" value="${params.name}" />
          </p>
          <p>
            Email: <input type="input" name="email" value="${params.email}" />
          </p>
  
    - filename: user_create.xxhtml
      desc:     import()
      content*:
       "python": |
          <form action="create" method="post">
          <?py include(':form') ?> 
            <input type="submit" value="Create" />
          </form>
       "ruby": |
          <form action="create" method="post">
          <?rb import :form ?>
            <input type="submit" value="Create" />
          </form>
       "perl": |
          <form action="create" method="post">
          <?pl include(':form'); ?> 
            <input type="submit" value="Create" />
          </form>
       "js": |
          <form action="create" method="post">
          <?js include(':form'); ?> 
            <input type="submit" value="Create" />
          </form>
  
    - filename: user_edit.xxhtml
      desc:     import(append=false)
      content*:
       "python": |
          <form action="edit" method="post">
          #{include('user_form.pyhtml', False)}
            <input type="submit" value="Edit" />
          </form>
       "ruby": |
          <form action="edit" method="post">
          #{import 'user_form.rbhtml', false}
            <input type="submit" value="Edit" />
          </form>
       "perl": |
          <form action="edit" method="post">
          <?pl include('user_form.plhtml')?>
	  
            <input type="submit" value="Edit" />
          </form>
       "js": |
          <form action="edit" method="post">
          <?js include('user_form.plhtml')?>
	  
            <input type="submit" value="Edit" />
          </form>
  
    - filename: user_sidemenu.xxhtml
      desc:     _engine.render()
      content*:
       "python": |
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
       "ruby": |
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
       "perl": |
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
       "js": |
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
  
    - filename: footer.html
      desc:     _engine.evaluate()
      content*:
       "python": &footer |
          <hr />
          <address>
            copyright&copy;2007 kuwata-lab.com
          </address>
       "ruby": *footer
       "perl": *footer
       "js": *footer
  
  expected:
  
    - name:     user_list_nolayout
      content*:
       "python": &c01 |
          <ul>
            <li>Robert
                (bob@example.com)</li>
            <li>Margalette
                (meg@example.com)</li>
            <li>William
                (bill@example.com)</li>
          </ul>
       "ruby": *c01
       "perl": *c01
       "js": *c01
  
    - name:     user_show_nolayout
      content*:
       "python": &c02 |
          <p>
            Name: Robert<br />
            Email: bob@example.com
          </p>
       "ruby": *c02
       "perl": *c02
       "js": *c02
  
    - name:     user_create_nolayout
      content*:
       "python": &c03 |
          <form action="create" method="post">
          <p>
            Name: <input type="input" name="name" value="" />
          </p>
          <p>
            Email: <input type="input" name="email" value="" />
          </p>
            <input type="submit" value="Create" />
          </form>
       "ruby": *c03
       "perl": *c03
       "js": *c03
  
    - name:     user_edit_nolayout
      content*:
       "python": &c04 |
          <form action="edit" method="post">
          <p>
            Name: <input type="input" name="name" value="Robert" />
          </p>
          <p>
            Email: <input type="input" name="email" value="bob@example.com" />
          </p>
  
            <input type="submit" value="Edit" />
          </form>
       "ruby": *c04
       "perl": *c04
       "js": *c04
  
    - name:     user_list_withlayout
      content*:
       "python": &c05 |
          <html>
            <body>
              <h1>Users List</h1>
              <div id="sidemenu">
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
              </div>
              <div id="maincontent">
          <ul>
            <li>Robert
                (bob@example.com)</li>
            <li>Margalette
                (meg@example.com)</li>
            <li>William
                (bill@example.com)</li>
          </ul>
  
              </div>
              <div id="footer">
          <hr />
          <address>
            copyright&copy;2007 kuwata-lab.com
          </address>
  
              </div>
            </body>
          </html>
       "ruby": *c05
       "perl": *c05
       "js": *c05
  
    - name:     user_show_withlayout
      content*:
       "python": &c06 |
          <html>
            <body>
              <h1>Show User</h1>
              <div id="sidemenu">
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
              </div>
              <div id="maincontent">
          <p>
            Name: Robert<br />
            Email: bob@example.com
          </p>
  
              </div>
              <div id="footer">
          <hr />
          <address>
            copyright&copy;2007 kuwata-lab.com
          </address>
          
              </div>
            </body>
          </html>
       "ruby": *c06
       "perl": *c06
       "js": *c06
  
    - name:     user_create_withlayout
      content*:
       "python": &c07 |
          <html>
            <body>
              <h1>Create User</h1>
              <div id="sidemenu">
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
              </div>
              <div id="maincontent">
          <form action="create" method="post">
          <p>
            Name: <input type="input" name="name" value="" />
          </p>
          <p>
            Email: <input type="input" name="email" value="" />
          </p>
            <input type="submit" value="Create" />
          </form>
  
              </div>
              <div id="footer">
          <hr />
          <address>
            copyright&copy;2007 kuwata-lab.com
          </address>
  
              </div>
            </body>
          </html>
       "ruby": *c07
       "perl": *c07
       "js": *c07
  
    - name:     user_edit_withlayout
      content*:
       "python": &c08 |
          <html>
            <body>
              <h1>Edit User</h1>
              <div id="sidemenu">
          <a href="/user/list">List</a><br />
          <a href="/user/create">Create</a><br />
              </div>
              <div id="maincontent">
          <form action="edit" method="post">
          <p>
            Name: <input type="input" name="name" value="Robert" />
          </p>
          <p>
            Email: <input type="input" name="email" value="bob@example.com" />
          </p>
  
            <input type="submit" value="Edit" />
          </form>
  
              </div>
              <div id="footer">
          <hr />
          <address>
            copyright&copy;2007 kuwata-lab.com
          </address>
  
              </div>
            </body>
          </html>
       "ruby": *c08
       "perl": *c08
       "js": *c08


### -- for capture test

- name:  test_capture_and_echo
  layout*:
   "python": |
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
            <title>${title}</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="style.css" />
          </head>
          <body>
            <h1>${title}</h1>
        
            <div id="main_content">
        <?py echo(main_content) ?>
            </div>
        
            <div id="footer">
        <?py echo(footer) ?>
            </div>
        
          </body>
        </html>
   "ruby": |
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
            <title>${@title}</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="style.css" />
          </head>
          <body>
            <h1>${@title}</h1>
        
            <div id="main_content">
            <?rb echo(@main_content) ?>
            </div>
        
            <div id="footer">
            <?rb echo(@footer) ?>
            </div>
        
          </body>
        </html>
   "perl": |
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
            <title>[=$title=]</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="style.css" />
          </head>
          <body>
            <h1>[=$title=]</h1>
        
            <div id="main_content">
        <?pl echo($main_content) ?>
            </div>
        
            <div id="footer">
        <?pl echo($footer) ?>
            </div>
        
          </body>
        </html>
   "js": |
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
            <title>${title}</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="style.css" />
          </head>
          <body>
            <h1>${title}</h1>
        
            <div id="main_content">
        <?js echo(main_content) ?>
            </div>
        
            <div id="footer">
        <?js echo(footer) ?>
            </div>
        
          </body>
        </html>

  content*:
   "python": |
        <html>
          <body>
            <h1><?py
        start_capture('title')
        ?>Capturing Example<?py
        stop_capture()
        ?></h1>
        
        <?py start_capture('main_content') ?>
            <table>
        <?py for i, item in enumerate(items): ?>
        <?py     color = i % 2 == 0 and '#FFCCCC' or '#CCCCFF' ?>
              <tr bgcolor="#{color}">
                <td>${item}</td>
              </tr>
        <?py #endfor ?>
            </table>
        <?py stop_capture(False) ?>
        <?py _context['main_content'] = main_content ?>
        
        <?py start_capture() ?>
            <hr>
            <address>
              <a href="mailto:webmaster@example.com">webmaster@example.com</a>
            </address>
        <?py _context['footer'] = stop_capture(False) ?>
        
          </body>
        </html>
   "ruby": |
        <html>
          <body>
            <h1><?rb start_capture(:title) do ?>Capturing Example<?rb end ?></h1>
        
            <?rb start_capture(:main_content) ?>
            <table>
              <?rb @items.each_with_index do |item, i| ?>
              <?rb   color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ?>
              <tr bgcolor="#{color}">
                <td>${item}</td>
              </tr>
              <?rb end ?>
            </table>
            <?rb stop_capture() ?>
        
            <?rb start_capture() ?>
            <hr>
            <address>
              <a href="mailto:webmaster@example.com">webmaster@example.com</a>
            </address>
            <?rb @footer = stop_capture() ?>
        
          </body>
        </html>
   "perl": |
        <html>
          <body>
            <h1><?pl start_capture('title') ?>Capturing Example<?pl stop_capture() ?></h1>
        
        <?pl start_capture('main_content') ?>
            <table>
	<?pl my $i = 0; ?>
        <?pl for my $item (@$items) { ?>
        <?pl     $color = $i++ % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; ?>
              <tr bgcolor="[==$color=]">
                <td>[=$item=]</td>
              </tr>
        <?pl } ?>
            </table>
        <?pl stop_capture() ?>
        
        <?pl start_capture('footer');?>
            <hr>
            <address>
              <a href="mailto:webmaster@example.com">webmaster@example.com</a>
            </address>
        <?pl stop_capture();?>
        
          </body>
        </html>
   "js": |
        <html>
          <body>
            <h1><?js startCapture('title') ?>Capturing Example<?js stopCapture() ?></h1>
        
        <?js startCapture('main_content') ?>
            <table>
        <?js for (var i = 0, n = items.length; i < n; i++) { ?>
        <?js     var color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ?>
              <tr bgcolor="#{color}">
                <td>${item[i]}</td>
              </tr>
        <?js } ?>
            </table>
        <?js stopCapture() ?>
        
        <?js start_capture('footer') ?>
            <hr>
            <address>
              <a href="mailto:webmaster@example.com">webmaster@example.com</a>
            </address>
        <?js stop_capture(False) ?>
        
          </body>
        </html>

  expected*:
   "python": &ex11 |
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <head>
            <title>Capturing Example</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="style.css" />
          </head>
          <body>
            <h1>Capturing Example</h1>
        
            <div id="main_content">
            <table>
              <tr bgcolor="#FFCCCC">
                <td>AAA</td>
              </tr>
              <tr bgcolor="#CCCCFF">
                <td>BBB</td>
              </tr>
              <tr bgcolor="#FFCCCC">
                <td>CCC</td>
              </tr>
            </table>
            </div>
        
            <div id="footer">
            <hr>
            <address>
              <a href="mailto:webmaster@example.com">webmaster@example.com</a>
            </address>
            </div>
        
          </body>
        </html>
   "ruby": *ex11
   "perl": *ex11
   "js": *ex11


### -- for captured_as() function test

- name:  test_captured_as
  baselayout*:
   "python": |
        <html>
         <body>
        
          <!-- HEADER -->
        <?py if not captured_as('header_part'): ?>
           <img src="img/logo.png" alt="logo" ?>
        <?py #end ?>
          <!-- /HEADER -->
        
          <!-- CONTENT -->
        <?py _buf.append(content_part) ?>
          <!-- /CONTENT -->
        
          <!-- FOOTER -->
        <?py if not captured_as('footer_part'): ?>
           <hr />
           <em>webmaster@example.com</em>
        <?py #end ?>
          <!-- /FOOTER -->
          
         </body>
        </html>
   "ruby": |
        <html>
         <body>
        
          <!-- HEADER -->
        <?rb unless captured_as('header_part') ?>
           <img src="img/logo.png" alt="logo" ?>
        <?rb end ?>
          <!-- /HEADER -->
        
          <!-- CONTENT -->
        <?rb _buf << @content_part ?>
          <!-- /CONTENT -->
        
          <!-- FOOTER -->
        <?rb unless captured_as('footer_part') ?>
           <hr />
           <em>webmaster@example.com</em>
        <?rb end ?>
          <!-- /FOOTER -->
          
         </body>
        </html>
   "perl": |
        <html>
         <body>
        
          <!-- HEADER -->
        <?pl start_placeholder('header_part') ?>
           <img src="img/logo.png" alt="logo" ?>
        <?pl stop_placeholder() ?>
          <!-- /HEADER -->
        
          <!-- CONTENT -->
        <?pl push(@_buf, $content_part); ?>
          <!-- /CONTENT -->
        
          <!-- FOOTER -->
        <?pl start_placeholder('footer_part'); ?>
           <hr />
           <em>webmaster@example.com</em>
        <?pl stop_placeholder() ?>
          <!-- /FOOTER -->
          
         </body>
        </html>
   "js": |
        <html>
         <body>
        
          <!-- HEADER -->
        <?js startPlaceholder('header_part') ?>
           <img src="img/logo.png" alt="logo" ?>
        <?js endPlaceholder() ?>
          <!-- /HEADER -->
        
          <!-- CONTENT -->
        <?js _buf.push(content_part); ?>
          <!-- /CONTENT -->
        
          <!-- FOOTER -->
        <?js startPlaceholder('footer_part') ?>
           <hr />
           <em>webmaster@example.com</em>
        <?js stopPlaceholder() ?>
          <!-- /FOOTER -->
          
         </body>
        </html>

  customlayout*:
   "python": |
        <?py _context['_layout'] = 'baselayout.pyhtml' ?>
        
        <?py start_capture('footer_part') ?>
        <address style="text-align:right">
          copyright&copy; 2007 kuwata-lab all rights reserved<br />
          <a href="webmaster&#64;kuwata-lab.com">webmaster&#64;kuwata-lab.com</a>
        </address>
        <?py stop_capture() ?>
   "ruby": |
        <?rb _context['_layout'] = 'baselayout.rbhtml' ?>
        
        <?rb start_capture('footer_part') ?>
        <address style="text-align:right">
          copyright&copy; 2007 kuwata-lab all rights reserved<br />
          <a href="webmaster&#64;kuwata-lab.com">webmaster&#64;kuwata-lab.com</a>
        </address>
        <?rb stop_capture() ?>
   "perl": |
        <?pl $_context->{_layout} = 'baselayout.plhtml'; ?>
        
        <?pl start_capture('footer_part') ?>
        <address style="text-align:right">
          copyright&copy; 2007 kuwata-lab all rights reserved<br />
          <a href="webmaster&#64;kuwata-lab.com">webmaster&#64;kuwata-lab.com</a>
        </address>
        <?pl stop_capture() ?>
   "js": |
        <?js _context._layout = 'baselayout.jshtml'; ?>
        
        <?js startCapture('footer_part') ?>
        <address style="text-align:right">
          copyright&copy; 2007 kuwata-lab all rights reserved<br />
          <a href="webmaster&#64;kuwata-lab.com">webmaster&#64;kuwata-lab.com</a>
        </address>
        <?js stopCapture() ?>

  content*:
   "python": |
        <?py _context['_layout'] = 'customlayout.pyhtml' ?>
        
        <?py start_capture('content_part') ?>
        <ul>
        <?py for item in items: ?>
          <li>${item}</li>
        <?py #end ?>
        </ul>
        <?py stop_capture() ?>
   "ruby": |
        <?rb @_layout = 'customlayout.rbhtml' ?>
        
        <?rb start_capture(:content_part) ?>
        <ul>
        <?rb for item in @items ?>
          <li>${item}</li>
        <?rb end ?>
        </ul>
        <?rb stop_capture() ?>
   "perl": |
        <?pl $_context->{_layout} = 'customlayout.plhtml'; ?>
        
        <?pl start_capture('content_part') ?>
        <ul>
        <?pl for my $item (@$items) { ?>
          <li>[=$item=]</li>
        <?pl } ?>
        </ul>
        <?pl stop_capture() ?>
   "js": |
        <?js _context._layout = 'customlayout.pyhtml'; ?>
        
        <?js start_capture('content_part') ?>
        <ul>
        <?js for (var i = 0, n = items.length; i < n; i++) { ?>
          <li>${items[i]}</li>
        <?js } ?>
        </ul>
        <?js stop_capture() ?>

  context: { items: ['AAA', 'BBB', 'CCC'] }
  expected: |
        <html>
         <body>
        
          <!-- HEADER -->
           <img src="img/logo.png" alt="logo" ?>
          <!-- /HEADER -->
        
          <!-- CONTENT -->
        <ul>
          <li>AAA</li>
          <li>BBB</li>
          <li>CCC</li>
        </ul>
          <!-- /CONTENT -->
        
          <!-- FOOTER -->
        <address style="text-align:right">
          copyright&copy; 2007 kuwata-lab all rights reserved<br />
          <a href="webmaster&#64;kuwata-lab.com">webmaster&#64;kuwata-lab.com</a>
        </address>
          <!-- /FOOTER -->
          
         </body>
        </html>





### -- for local layout test

#local_layout_test:
- name:  test_local_layout
  layout_html*:
   "python": |
        <html>
          <body>
        #{_content}
          </body>
        </html>
   "ruby": |
        <html>
          <body>
        #{@_content}
          </body>
        </html>
   "perl": |
        <html>
          <body>
        [==$_content=]
          </body>
        </html>
   "js": |
        <html>
          <body>
        #{_content}
          </body>
        </html>

  layout_xhtml*:
   "python": |
        <?xml version="1.0" encoding="UTF-8" ?>
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <body>
        #{_content}
          </body>
        </html>
   "ruby": |
        <?xml version="1.0" encoding="UTF-8" ?>
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <body>
        #{@_content}
          </body>
        </html>
   "perl": |
        <?xml version="1.0" encoding="UTF-8" ?>
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <body>
        [==$_content=]
          </body>
        </html>
   "js": |
        <?xml version="1.0" encoding="UTF-8" ?>
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <body>
        #{_content}
          </body>
        </html>

  content_html*:
   "python": |
        <h1>hello #{user}!</h1>
   "ruby": |
        <h1>hello #{@user}!</h1>
   "perl": |
        <h1>hello [=$user=]!</h1>
   "js": |
        <h1>hello #{user}!</h1>

  context*:
   "python": { user: world }
   "ruby":   { user: world }
   "perl":   { user: world }
   "js":     { user: world }

  expected_nolayout*:
   "python": |
        <h1>hello world!</h1>
   "ruby": |
        <h1>hello world!</h1>
   "perl": |
        <h1>hello world!</h1>
   "js": |
        <h1>hello world!</h1>

  expected_html*:
   "python": &expected11 |
        <html>
          <body>
        <h1>hello world!</h1>
        
          </body>
        </html>
   "ruby": *expected11
   "perl": *expected11
   "js": *expected11

  expected_xhtml*:
   "python": &expected12 |
        <?xml version="1.0" encoding="UTF-8" ?>
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
          <body>
        <h1>hello world!</h1>
        
          </body>
        </html>
   "ruby": *expected12
   "perl": *expected12
   "js": *expected12


### -- for caching test

#caching_test:
- name:  test_cachefile
  desc:  mtime of cachefile
  layout*:
   "python": |
        <html>
          <head>
            <title>${title}</title>
          </head>
          <body>
            <h1>${title}</h1>
            <div id="content">
        #{_content}
            </div>
          </body>
        </html>
   "ruby": |
        <html>
          <head>
            <title>${@title}</title>
          </head>
          <body>
            <h1>${@title}</h1>
            <div id="content">
        #{@_content}
            </div>
          </body>
        </html>
   "perl": |
        <html>
          <head>
            <title>[=$title=]</title>
          </head>
          <body>
            <h1>[=$title=]</h1>
            <div id="content">
        [==$_content=]
            </div>
          </body>
        </html>
   "js": |
        <html>
          <head>
            <title>${title}</title>
          </head>
          <body>
            <h1>${title}</h1>
            <div id="content">
        #{_content}
            </div>
          </body>
        </html>

  page*:
   "python": |
        <?py _context['title'] = 'Create Account' ?>
        <form action="create" method="post">
        <?py include(':form') ?>
          <input type="submit" value="Create" />
        </form>
   "ruby": |
        <?rb @title = 'Create Account' ?>
        <form action="create" method="post">
        <?rb import(:form) ?>
          <input type="submit" value="Create" />
        </form>
   "perl": |
        <?pl $_context->{title} = 'Create Account'; ?>
        <form action="create" method="post">
        <?pl include(':form') ?>
          <input type="submit" value="Create" />
        </form>
   "js": |
        <?js _context.title = 'Create Account'; ?>
        <form action="create" method="post">
        <?js include(':form') ?>
          <input type="submit" value="Create" />
        </form>

  form*:
   "python": |5
          <p>
            Account:
            <input type="text" name="account" value="${params.get('account')}" />
          </p>
          <p>
            Password:
            <input type="text" name="password" value="${params.get('password')}" />
          </p>
   "ruby": |5
          <p>
            Account:
            <input type="text" name="account" value="${@params['account']}" />
          </p>
          <p>
            Password:
            <input type="text" name="password" value="${@params['password']}" />
          </p>
   "perl": |5
          <p>
            Account:
            <input type="text" name="account" value="[=$params->{account}=]" />
          </p>
          <p>
            Password:
            <input type="text" name="password" value="[=$params->{password}=]" />
          </p>
   "js": |5
          <p>
            Account:
            <input type="text" name="account" value="${params.account}" />
          </p>
          <p>
            Password:
            <input type="text" name="password" value="${params.password}" />
          </p>

  expected*:
   "python": &caching_test_expected |
        <html>
          <head>
            <title>Create Account</title>
          </head>
          <body>
            <h1>Create Account</h1>
            <div id="content">
        <form action="create" method="post">
          <p>
            Account:
            <input type="text" name="account" value="" />
          </p>
          <p>
            Password:
            <input type="text" name="password" value="" />
          </p>
          <input type="submit" value="Create" />
        </form>
        
            </div>
          </body>
        </html>
   "ruby": *caching_test_expected
   "perl": *caching_test_expected
   "js": *caching_test_expected


### -- for layout inheritance test

#change_layout:
- name:  test_change_layout

  baselayout*:
   "python": |
        <html>
          <body>
        <?py if _context.has_key('title'): ?>
            <h1>${title}</h1>
        <?py #end ?>
        <?py _buf.append(_content) ?>
          </body>
        </html>
   "ruby": |
        <html>
          <body>
        <?rb if @title ?>
            <h1>${@title}</h1>
        <?rb end ?>
        <?rb _buf << @_content ?>
          </body>
        </html>
   "perl": |
        <html>
          <body>
        <?pl if (exists $_context->{title}) { ?>
            <h1>[=$title=]</h1>
        <?pl } ?>
        <?pl push(@_buf, $_content); ?>
          </body>
        </html>
   "js": |
        <html>
          <body>
        <?js if (_context.title) { ?>
            <h1>${title}</h1>
        <?js } ?>
        <?js _buf.append(_content) ?>
          </body>
        </html>

  customlayout*:
   "python": |
        <?py ## use default layout template name ?>
        <?py _context['_layout'] = True ?>
        <div id="content">
        <?py _buf.append(_content) ?>
        </div>
   "ruby": |
        <?rb ## use default layout template name ?>
        <?rb @_layout = true ?>
        <div id="content">
        <?rb _buf << @_content ?>
        </div>
   "perl": |
        <?pl ## use default layout template name ?>
        <?pl $_context->{_layout} = 1; ?>
        <div id="content">
        <?pl push(@_buf, $_content); ?>
        </div>
   "js": |
        <?js // use default layout template name ?>
        <?js _context._layout = 1; ?>
        <div id="content">
        <?js _buf.push(_content); ?>
        </div>

  content*:
   "python": |
        <?py _context['title'] = 'Changing Layout Template Test' ?>
        <?py ## specify layout template name ?>
        <?py _context['_layout'] = 'customlayout.pyhtml' ?>
        foo
        bar
        baz
   "ruby": |
        <?rb @title = 'Changing Layout Template Test' ?>
        <?rb ## specify layout template name ?>
        <?rb @_layout = 'customlayout.rbhtml' ?>
        foo
        bar
        baz
   "perl": |
        <?pl $_context->{title} = 'Changing Layout Template Test'; ?>
        <?pl ## specify layout template name ?>
        <?pl $_context->{_layout} = 'customlayout.plhtml'; ?>
        foo
        bar
        baz
   "js": |
        <?js _context.title = 'Changing Layout Template Test'; ?>
        <?js ## specify layout template name ?>
        <?js _context._layout = 'customlayout.jshtml'; ?>
        foo
        bar
        baz

  expected*:
   "python": &expected_change_layout |
        <html>
          <body>
            <h1>Changing Layout Template Test</h1>
        <div id="content">
        foo
        bar
        baz
        </div>
          </body>
        </html>
   "ruby": *expected_change_layout
   "perl": *expected_change_layout
   "js":   *expected_change_layout



## -- context_scope
- name:  test_context_scope
  desc:  context scope
  base*:
   "python": |
        <?py _context['x1'] = 10 ?>
        <?py x2 = 20 ?>
        <?py include('part.pyhtml') ?>
        [base] _context.get('y1') = #{repr(_context.get('y1'))}
        [base] _context.get('y2') = #{repr(_context.get('y2'))}
        [base] locals().get('y1') = #{repr(locals().get('y1'))}
        [base] locals().get('y2') = #{repr(locals().get('y2'))}
   "ruby": |
        <?rb @x1 = 10 ?>
        <?rb x2 = 20 ?>
        <?rb import('part.rbhtml') ?>
        [base] @y1 = #{@y1.inspect}
        [base] @y2 = #{@y2.inspect}
	[base] local_variables() = #{local_variables().inspect()}
   "perl": |
        <?pl $_context->{x1} = 10; ?>
        <?pl my $x2 = 20; ?>
        <?pl include('part.plhtml') ?>
        [base] _context->{y1} = '[=$_context->{y1}=]'
        [base] _context->{y2} = '[=$_context->{y2}=]'
   "js": |
  part*:
   "python": |
        [part] _context.get('x1') = #{repr(_context.get('x1'))}
        [part] _context.get('x2') = #{repr(_context.get('x2'))}
        [part] locals().get('x1') = #{repr(locals().get('x1'))}
        [part] locals().get('x2') = #{repr(locals().get('x2'))}
        <?py _context['y1'] = 30 ?>
        <?py y2 = 40 ?>
   "ruby": |
        [part] @x1 = #{@x1.inspect}
        [part] @x2 = #{@x2.inspect}
        [part] local_variables = #{local_variables().inspect}
        <?rb @y1 = 30 ?>
        <?rb y2 = 40 ?>
   "perl": |
        [part] _context->{x1} = '[=$_context->{x1}=]'
        [part] _context->{x2} = '[=$_context->{x2}=]'
        <?pl $_context->{y1} = 30; ?>
        <?pl my $y2 = 40; ?>
   "js": |
  expected*:
   "python": |
        [part] _context.get('x1') = 10
        [part] _context.get('x2') = None
        [part] locals().get('x1') = 10
        [part] locals().get('x2') = None
        [base] _context.get('y1') = 30
        [base] _context.get('y2') = None
        [base] locals().get('y1') = None
        [base] locals().get('y2') = None
#       _context.get('x1') = None
#       _context.get('x2') = 20
#       locals().get('x1') = None
#       locals().get('x2') = 20
#       _context.get('y1') = None
#       _context.get('y2') = None
#       locals().get('y1') = 30
#       locals().get('y2') = None
   "ruby": |
	[part] @x1 = 10
	[part] @x2 = nil
	[part] local_variables = ["_buf", "_context"]
	[base] @y1 = 30
	[base] @y2 = nil
	[base] local_variables() = ["x2", "_buf", "_context"]
   "perl": |
	[part] _context->{x1} = '10'
	[part] _context->{x2} = ''
	[base] _context->{y1} = '30'
	[base] _context->{y2} = ''
   "js": |


## -- template args
- name:  test_template_args
  content*:
   "python": |
        <?py #@ARGS a ?>
        a = #{repr(a)}
        b = #{repr(b)}
   "ruby": |
        <?rb #@ARGS a ?>
        a = #{a}
        b = #{b}
   "perl": |
        <?pl #@ARGS x ?>
        x = [=$x=]
        y = [=$y=]
   "js": |
        <?js //@ARGS a ?>
        a = #{Tenjin.inspect(a)}
        b = #{Tenjin.inspect(b)}
  exception*:
   "python": NameError
   "ruby": NameError
   "perl": 
   "js": |
  errormsg*:
   "python": name 'b' is not defined
   "ruby": "undefined local variable or method `b' for #<Tenjin::Context>"
   "perl": |
	*** Error: content.plhtml
	Global symbol "$y" requires explicit package name at (eval 999) line 3.
   "js": |
  context: { a: 10, b: 20 }
  expected*:
   "python": |
        a = 10
        b = 20
   "ruby": |
        a = 10
        b = 20
   "perl": 
   "js": |


## -- template args are stored into and loaded from cache file?
- name:  test_cached_contents
  desc:  cached script and args are stored into/loaded from cachefile correctly?
  input1*:
    "python": |
	<p>
	<?py #@ARGS x,y  ,  z?>
	  x = #{x}, y = #{y}, z = #{z}
	</p>
    "ruby": |
	<p>
	<?rb #@ARGS x,y  ,  z?>
	  x = #{x}, y = #{y}, z = #{z}
	</p>
  script1*:
    "python": |
	_buf.extend(('''<p>\n''', ));
	x = _context.get('x'); y = _context.get('y'); z = _context.get('z'); 
	_buf.extend(('''  x = ''', to_str(x), ''', y = ''', to_str(y), ''', z = ''', to_str(z), '''
	</p>\n''', ));
    "ruby": |4
	 _buf << %Q`<p>\n`
	 x = @x; y = @y; z = @z;
	 _buf << %Q`  x = #{x}, y = #{y}, z = #{z}
	</p>\n`
  cache1*:
    "python": |
	_buf.extend(('''<p>\n''', ));
	x = _context.get('x'); y = _context.get('y'); z = _context.get('z'); 
	_buf.extend(('''  x = ''', to_str(x), ''', y = ''', to_str(y), ''', z = ''', to_str(z), '''
	</p>\n''', ));
    "ruby": |
	#@ARGS x,y,z
	 _buf << %Q`<p>\n`
	 x = @x; y = @y; z = @z;
	 _buf << %Q`  x = #{x}, y = #{y}, z = #{z}
	</p>\n`
  args1: [ x, y, z ]
  input2*:
    "python": |
	<p>
	<?py #@ARGS ?>
	  x = #{x}, y = #{y}, z = #{z}
	</p>
    "ruby": |
	<p>
	<?rb #@ARGS ?>
	  x = #{x}, y = #{y}, z = #{z}
	</p>
  script2*:
    "python": |
	_buf.extend(('''<p>\n''', ));
	
	_buf.extend(('''  x = ''', to_str(x), ''', y = ''', to_str(y), ''', z = ''', to_str(z), '''
	</p>\n''', ));
    "ruby": |4
	 _buf << %Q`<p>\n`
	
	 _buf << %Q`  x = #{x}, y = #{y}, z = #{z}
	</p>\n`
  cache2*:
    "python": |
	_buf.extend(('''<p>\n''', ));
	
	_buf.extend(('''  x = ''', to_str(x), ''', y = ''', to_str(y), ''', z = ''', to_str(z), '''
	</p>\n''', ));
    "ruby": |4
        #@ARGS 
	 _buf << %Q`<p>\n`
	
	 _buf << %Q`  x = #{x}, y = #{y}, z = #{z}
	</p>\n`
  args2: [ ]


## -- for template path test
- name:  test_template_path
  common_layout*:
   "python": |
        <html>
          <body>
        #{_content}
        <?py include(':footer') ?>
          </body>
        </html>
   "ruby": |
        <html>
          <body>
        #{@_content}
        <?rb import(:footer) ?>
          </body>
        </html>
   "perl": |
        <html>
          <body>
        [==$_content=]
        <?pl include(':footer'); ?>
          </body>
        </html>
   "js": |
        <html>
          <body>
        #{_content}
        <?js include(':footer'); ?>
          </body>
        </html>

  common_body*:
   "python": |
        <ul>
        <?py for item in items: ?>
          <li>${item}</li>
        <?py #end ?>
        </ul>
   "ruby": |
        <ul>
        <?rb for item in @items ?>
          <li>${item}</li>
        <?rb end ?>
        </ul>
   "perl": |
        <ul>
        <?pl for my $item (@$items) { ?>
          <li>[=$item=]</li>
        <?pl } ?>
        </ul>
   "js": |
        <ul>
        <?js for (var i = 0, n = items.length; i < n; i++) { ?>
          <li>${items[i]}</li>
        <?js } ?>
        </ul>

  common_footer*:
   "python": &common_footer |
        <hr />
        <address>
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </address>
   "ruby": *common_footer
   "perl": *common_footer
   "js":   *common_footer

  user_layout*:
   "python": |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <?py _buf.append(_content) ?>
        <?py include(':footer') ?>
          </body>
        </html>
   "ruby": |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <?rb _buf << @_content ?>
        <?rb import(:footer) ?>
          </body>
        </html>
   "perl": |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        [==$_content==]
        <?pl include(':footer') ?>
          </body>
        </html>
   "js": |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <?js echo(_content) ?>
        <?js include(':footer') ?>
          </body>
        </html>

  user_body*:
   "python": |
        <table>
        <?py for item in items: ?>
          <tr><td>${item}</td></tr>
        <?py #end ?>
        </table>
   "ruby": |
        <table>
        <?rb for item in @items ?>
          <tr><td>${item}</td></tr>
        <?rb end ?>
        </table>
   "perl": |
        <table>
        <?pl for my $item (@$items) { ?>
          <tr><td>[=$item=]</td></tr>
        <?pl } ?>
        </table>
   "js": |
        <table>
        <?js for (var i = 0, n = items.length; i < n; i++) { ?>
          <tr><td>${items[i]}</td></tr>
        <?js } ?>
        </table>

  user_footer*:
   "python": &user_footer |
        <div class="footer" style="margin-top: 20px; background-color: gray">
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </div>
   "ruby": *user_footer
   "perl": *user_footer
   "js": *user_footer

  expected_common_common_common*:
   "python": &expected41 |
        <html>
          <body>
        <ul>
          <li>AAA</li>
          <li>BBB</li>
          <li>CCC</li>
        </ul>
        
        <hr />
        <address>
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </address>
          </body>
        </html>
   "ruby": *expected41
   "perl": *expected41
   "js": *expected41

  expected_user_common_common*:
   "python": &expected42 |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <ul>
          <li>AAA</li>
          <li>BBB</li>
          <li>CCC</li>
        </ul>
        <hr />
        <address>
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </address>
          </body>
        </html>
   "ruby": *expected42
   "perl": *expected42
   "js": *expected42

  expected_common_user_common*:
   "python": &expected43 |
        <html>
          <body>
        <table>
          <tr><td>AAA</td></tr>
          <tr><td>BBB</td></tr>
          <tr><td>CCC</td></tr>
        </table>
        
        <hr />
        <address>
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </address>
          </body>
        </html>
   "ruby": *expected43
   "perl": *expected43
   "js": *expected43

  expected_user_user_common*:
   "python": &expected44 |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <table>
          <tr><td>AAA</td></tr>
          <tr><td>BBB</td></tr>
          <tr><td>CCC</td></tr>
        </table>
        <hr />
        <address>
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </address>
          </body>
        </html>
   "ruby": *expected44
   "perl": *expected44
   "js": *expected44

  expected_common_common_user*:
   "python": &expected45 |
        <html>
          <body>
        <ul>
          <li>AAA</li>
          <li>BBB</li>
          <li>CCC</li>
        </ul>
        
        <div class="footer" style="margin-top: 20px; background-color: gray">
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </div>
          </body>
        </html>
   "ruby": *expected45
   "perl": *expected45
   "js": *expected45

  expected_user_common_user*:
   "python": &expected46 |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <ul>
          <li>AAA</li>
          <li>BBB</li>
          <li>CCC</li>
        </ul>
        <div class="footer" style="margin-top: 20px; background-color: gray">
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </div>
          </body>
        </html>
   "ruby": *expected46
   "perl": *expected46
   "js": *expected46

  expected_common_user_user*:
   "python": &expected47 |
        <html>
          <body>
        <table>
          <tr><td>AAA</td></tr>
          <tr><td>BBB</td></tr>
          <tr><td>CCC</td></tr>
        </table>
        
        <div class="footer" style="margin-top: 20px; background-color: gray">
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </div>
          </body>
        </html>
   "ruby": *expected47
   "perl": *expected47
   "js":   *expected47

  expected_user_user_user*:
   "python": &expected48 |
        <?xml version="1.0" ?>
        <html xml:lang="en">
          <body>
        <table>
          <tr><td>AAA</td></tr>
          <tr><td>BBB</td></tr>
          <tr><td>CCC</td></tr>
        </table>
        <div class="footer" style="margin-top: 20px; background-color: gray">
          <a href="mailto:webmaster@localhost">webmaster@localhost</a>
        </div>
          </body>
        </html>
   "ruby": *expected48
   "perl": *expected48
   "js":   *expected48



## -- preprocessor

- name:  test_preprocessor
  testopts:  { preprocess: true }
  form*:    # <?PY ... ?>
    "python": |
        <?PY states = { "CA": "California", ?>
        <?PY            "NY": "New York", ?>
        <?PY            "FL": "Florida", } ?>
        <?PY # ?>
        <?py chk = { params['state']: ' checked="checked"' } ?>
        <?PY codes = states.keys() ?>
        <?PY codes.sort() ?>
        <select name="state">
          <option value="">-</option>
        <?PY for code in codes: ?>
          <option value="#{{code}}"#{chk.get(#{{repr(code)}}, '')}>${{states[code]}}</option>
        <?PY #endfor ?>
        </select>
    "ruby": |
        <?RB states = { :CA => "California", ?>
        <?RB            :NY => "New York",   ?>
        <?RB            :FL => "Florida", }  ?>
        <?rb chk = { @params['state'] => ' checked="checked"' } ?>
        <select name="state">
          <option value="">-</option>
        <?RB for code in states.keys.sort_by{|c| c.to_s} ?>
          <option value="#{{code}}"#{chk[#{{code.inspect}}]}>${{states[code]}}</option>
        <?RB end ?>
        </select>
    "perl": |
        <?PL my $states = { "CA"=>"California", ?>
        <?PL                "NY"=>"New York", ?>
        <?PL                "FL"=>"Florida", }; ?>
        <?pl my $chk = { $params->{state} => ' checked="checked"' }; ?>
        <select name="state">
          <option value="">-</option>
        <?PL for my $code (sort(keys %$states)) { ?>
          <option value="[*==$code=*]"[==$chk->{[*==$code=*]}=]>[*=$states->{$code}=*]</option>
        <?PL } ?>
        </select>
    "js": |
	<?JS var states = { "CA" : "California", ?>
	<?JS                "NY" : "New York",   ?>
	<?JS                "FL" : "Florida" };  ?>
	<?js var chk = {}; ?>
	<?js chk[params.state] = ' checked="checked"'; ?>
	<select name="state">
	  <option value="">-</option>
	<?JS var codes = []; ?>
	<?JS for (var code in states) { codes.push(code); } ?>
	<?JS codes.sort(); ?>
	<?JS for (var i = 0, n = codes.length; i < n; i++) { ?>
	<?JS     var code = codes[i]; ?>
	  <option value="#{{code}}"#{chk.#{{code}}||''}>${{states[code]}}</option>
	<?JS } ?>
	</select>

  create*:    # <?py include() ?>
    "python": |
        <?PY label = '"Create"' ?>
        <form action="#{{action}}">
        <?py include(':form') ?>
          <input type="submit" value="${{label}}">
        </form>
    "ruby": |
        <?RB label = '"Create"' ?>
        <form action="#{{@action}}">
          <?rb import(:form) ?>
          <input type="submit" value="${{label}}">
        </form>
    "perl": |
        <?PL my $label = '"Create"'; ?>
        <form action="[=$action=]">
          <?pl include(':form') ?>
          <input type="submit" value="[*=$label=*]">
        </form>
    "js": |
	<?JS var label = '"Create"'; ?>
	<form action="#{{action}}">
	  <?js include(':form'); ?>
	  <input type="submit" value="${{label}}">
	</form>

  update*:    # <?PY include() ?>
    "python": |
        <form action="#{{action}}">
        <?PY label = '"Update"' ?>
        <?PY include(':form') ?>
          <input type="submit" value="${{label}}">
        </form>
    "ruby": |
        <form action="#{{@action}}">
          <?RB label = '"Update"' ?>
          <?RB import(:form) ?>
          <input type="submit" value="${{label}}">
        </form>
    "perl": |
        <form action="[==$action=]">
        <?PL my $label = '"Update"'; ?>
        <?PL include(':form'); ?>
          <input type="submit" value="[*=$label=*]">
        </form>
    "js": |
	<?JS var label = '"Update"' ?>
	<form action="#{{action}}">
	  <?JS include(':form'); ?>
	  <input type="submit" value="${{label}}">
	</form>

  layout*:
    "python": |
        <html>
          <body>
            <h1>${title}</h1>
        <?py echo(_content) ?>
          </body>
        </html>
    "ruby": |
        <html>
          <body>
            <h1>${@title}</h1>
        <?rb echo(@_content) ?>
          </body>
        </html>
    "perl": |
        <html>
          <body>
            <h1>[=$title=]</h1>
        <?pl echo($_content); ?>
          </body>
        </html>
    "js": |
	<html>
	  <body>
	    <h1>${title}</h1>
	<?js echo(_content); ?>
	  </body>
	</html>

  expected1: |
        <html>
          <body>
            <h1>Create</h1>
        <form action="create">
        <select name="state">
          <option value="">-</option>
          <option value="CA">California</option>
          <option value="FL">Florida</option>
          <option value="NY" checked="checked">New York</option>
        </select>
          <input type="submit" value="&quot;Create&quot;">
        </form>
          </body>
        </html>

  expected2: |
        <html>
          <body>
            <h1>Update</h1>
        <form action="update">
        <select name="state">
          <option value="">-</option>
          <option value="CA">California</option>
          <option value="FL">Florida</option>
          <option value="NY" checked="checked">New York</option>
        </select>
          <input type="submit" value="&quot;Update&quot;">
        </form>
          </body>
        </html>

  cache1*:
    "python": |
        chk = { params['state']: ' checked="checked"' }
        _buf.extend(('''<select name="state">
          <option value="">-</option>
          <option value="CA"''', to_str(chk.get('CA', '')), '''>California</option>
          <option value="FL"''', to_str(chk.get('FL', '')), '''>Florida</option>
          <option value="NY"''', to_str(chk.get('NY', '')), '''>New York</option>
        </select>\n''', ));
    "ruby": |
    "perl": |
    "js": |
	var _buf = [];  var chk = {};
	 chk[params.state] = ' checked="checked"';
	 _buf.push('<select name="state">\n\
	  <option value="">-</option>\n\
	  <option value="CA"', chk.CA||'', '>California</option>\n\
	  <option value="FL"', chk.FL||'', '>Florida</option>\n\
	  <option value="NY"', chk.NY||'', '>New York</option>\n\
	</select>\n');
	_buf.join('')
  cache2*:
    "python": |
        _buf.extend(('''<form action="create">\n''', ));
        include(':form')
        _buf.extend(('''  <input type="submit" value="&quot;Create&quot;">
        </form>\n''', ));
    "ruby": |
    "perl": |
    "js": |
	var _buf = [];  _buf.push('<form action="create">\n');
	   _buf.push(_context._engine.render(':form', _context, false));
	 _buf.push('  <input type="submit" value="&quot;Create&quot;">\n\
	</form>\n');
	_buf.join('')
  cache3*:
    "python": |
        _buf.extend(('''<html>
          <body>
            <h1>''', escape(to_str(title)), '''</h1>\n''', ));
        echo(_content)
        _buf.extend(('''  </body>
        </html>\n''', ));
    "ruby": |
    "perl": |
    "js": |
	var _buf = [];  _buf.push('<html>\n\
	  <body>\n\
	    <h1>', escapeXml(title), '</h1>\n');
	 _buf.push(_content);
	 _buf.push('  </body>\n\
	</html>\n');
	_buf.join('')
  cache4*:
    "python": |
        _buf.extend(('''<form action="update">
        <select name="state">
          <option value="">-</option>
          <option value="CA">California</option>
          <option value="FL">Florida</option>
          <option value="NY" checked="checked">New York</option>
        </select>
          <input type="submit" value="&quot;Update&quot;">
        </form>\n''', ));
    "ruby": |
    "perl": |
    "js": |
	var _buf = [];  _buf.push('<form action="update">\n\
	<select name="state">\n\
	  <option value="">-</option>\n\
	  <option value="CA">California</option>\n\
	  <option value="FL">Florida</option>\n\
	  <option value="NY" checked="checked">New York</option>\n\
	</select>\n\
	  <input type="submit" value="&quot;Update&quot;">\n\
	</form>\n');
	_buf.join('')
