File: cookbook.html

package info (click to toggle)
libpetal-perl 2.23-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,088 kB
  • ctags: 162
  • sloc: perl: 4,738; xml: 726; makefile: 2
file content (86 lines) | stat: -rw-r--r-- 2,416 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<html>
  <head>
    <title>Petal Test</title>
    <style type="text/css">
      .active {
        background-color: yellow;
      }
    </style>
  </head>

  <body>
    <h1>Petal Test</h1>

    <h2>Basic - Passing a hashreference to Petal::process</h2>
    <table border="1">
      <tr petal:if="false: arrayref">
        <td>No elements</td>
      </tr>
      <tr petal:if="arrayref" petal:repeat="rec arrayref">
        <td>$rec/foo</td>
      </tr>
    </table>

    <p petal:content="string">String</p>
    <p petal:content="number">#</p>
    <p petal:content="foo">foo</p>



    <h2>Advanced - Invoking methods on objects</h2>
    <table border="1">
      <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Phone</th>
        <th>Active</th>
      </tr>
      <tr petal:if="false: records">
        <td colspan="5">No elements</td>
      </tr>
      <tr petal:if="records" petal:repeat="record records" petal:attr="class $record/is_current_id '1' 'active'">
        <td petal:content="record/id">ID</td>
        <td petal:content="string:$record/first_name $record/last_name">First Last</td>
        <td petal:content="record/phone">Phone</td>
        <td petal:condition="true:record/is_current_id" align="center">x</td>
      </tr>
    </table>

    <ul petal:repeat="record records">
      <li petal:condition="true:record/is_current_id" petal:content="string: Current id = $record/id">Current id</li>
    </ul>





    <h2>Advanced - Using CGI.pm to generate forms</h2>
    <table cellpadding="0" cellspacing="0" border="0" width="300">
      <tr>
        <th>Checkbox group</th>
        <th>Select group</th>
        <th>Radio button group</th>
      </tr>
      <tr>
        <td width="100">
          <span petal:replace="structure query/checkbox_group 'Choices' choices '' 'true'">
            <input name="Choices" type="checkbox" value="test">Test</input>
          </span>
        </td>

        <td width="100" valign="top">
          <span petal:replace="structure query/popup_menu 'Choices' choices '' 'true'">
            <input name="Choices" type="checkbox" value="test">Test</input>
          </span>
        </td>

        <td valign="top">
          <span petal:replace="structure query/radio_group 'Choices' choices '' 'true'">
            <input name="Choices" type="checkbox" value="test">Test</input>
          </span>
        </td>
      </tr>
    </table>

  </body>
</html>