'2008/07'에 해당되는 글 6건

  1. 2008.07.16 {템포2}6.다운로드
  2. 2008.07.16 {템포2}5.다이나믹블록
  3. 2008.07.16 {템포2}4.멤버함수
  4. 2008.07.16 {템포2}3.템플릿 문서
  5. 2008.07.16 {템포2}2.기초다지기
  6. 2008.07.16 {템포2}1.소개
phpsource/템플릿2008. 7. 16. 01:12
written: Jul 16 2008
TEMPO2 0.0.1 Beta2(2008.7.21)
아직 소개하지는 않았지만 스위치문에 대한 문법이 변경되어 수정하였습니다.> 스위치 속성은 "템포2 - 템플릿 문서" 중에서 "속성 switch" 항목을 참조바랍니다.
 
 
TEMPO2 0.0.1 Beta(2008.7.16)
Note: Tempo2 0.0.1 Beta 템플릿 엔진은 PHP 4.1.0 이상의 버전에서 동작합니다.
 
 
제 홈페이지에서 사용하고 있는 블로그밈 1.0b1을 후키템플릿 대신에 템포2로 포팅하여 실험삼아 운영하고 있습니다. 후키템플릿 문서를 템포2 문서로 변환하는 방법에 대하여는 가까운 시일 내에 따로 정리하여 올리겠습니다.

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}5.다이나믹블록  (0) 2008.07.16
{템포2}4.멤버함수  (0) 2008.07.16
{템포2}3.템플릿 문서  (0) 2008.07.16
{템포2}2.기초다지기  (0) 2008.07.16
{템포2}1.소개  (0) 2008.07.16
Posted by 방글24
phpsource/템플릿2008. 7. 16. 01:11
written: Jul 16 2008
반복되는 블록요소
Case #1
[code html;gutter:false] <table border="1"> <tr> <th bgcolor="#000066" style="color:white;">classify</th> <th bgcolor="#0000ff" style="color:white;">column1</th> <th bgcolor="#0000ff" style="color:white;">column2</th> <th bgcolor="#0000ff" style="color:white;">column3</th> </tr> <tempo id="eLoop"> <tr bgcolor="silver" style="height:30;"> <td align="center" bgcolor="#000066" style="color:white;"> <?=$column0?> </td> <td align="center"><?=$column1?></td> <td align="center"><?=$column2?></td> <td align="center"><?=$column3?></td> </tr> </tempo> </table> [/code]
< Template file : tempo.sample.htm >
[code php;gutter:false] <?php $columns[0]['column0'] = 'Country'; $columns[0]['column1'] = 'Korea'; $columns[0]['column2'] = 'USA'; $columns[0]['column3'] = 'Germany'; $columns[1]['column0'] = 'Capital city'; $columns[1]['column1'] = 'Seoul'; $columns[1]['column2'] = 'Washington DC'; $columns[1]['column3'] = 'Berlin'; $columns[2]['column0'] = 'Population'; $columns[2]['column1'] = '49,000,000'; $columns[2]['column2'] = '301,000,000'; $columns[2]['column3'] = '82,000,000'; include_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('sample', 'tempo.sample.htm'); $tempo->el['eLoop']->assign(''); foreach ($columns as $column) { extract($column); $tempo->el['eLoop']->assign('.'); } $tempo->el['sample']->assign(); $tempo->el['sample']->output(); ?> [/code]
< PHP coding >
< Result >

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}6.다운로드  (0) 2008.07.16
{템포2}4.멤버함수  (0) 2008.07.16
{템포2}3.템플릿 문서  (0) 2008.07.16
{템포2}2.기초다지기  (0) 2008.07.16
{템포2}1.소개  (0) 2008.07.16
Posted by 방글24
phpsource/템플릿2008. 7. 16. 01:10
written: Jul 16 2008
멤버함수의 분류
사용자에게 공개된 멤버함수는 크게 2개의 그룹으로 분류됩니다.
# 템플릿 문서를 다루는 멤버함수
  • 생성자
  • parse(string $template_handle, string $template_file)
  • parse_str(string $template_handle, string $template_string)
# 블록요소를 다루는 멤버함수
  • assign([string $operator])
  • output()
템플릿 문서를 다루는 멤버함수
[code php;gutter:false] require_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('eRoot', 'templates/tempo.sample.htm'); [/code]
< 템플릿 문서를 다루는 과정 >
생성자 Tempo2
생성자 Tempo2는 new 연산자를 통해 새로운 객체를 생성해 줍니다. PHP4에서는 반드시 참조연산자(&)를 사용하여야 하며, 그렇지 않으면 템플릿으로부터 만들어진 HTML 문서가 출력되지 않습니다.
[code php;gutter:false] $tempo = &new Tempo; [/code]
parse(string $template_handle, string $template_filename)
파일 형식의 템플릿 문서를 파싱해 줍니다. 첫번째 인수는 파싱된 최상위 블록요소인 템플릿 문서의 객체에 접근할 때 사용해야 하는 템플릿 핸들입니다. 두번째 인수는 템플릿 문서의 파일명을 나타냅니다.
[code php;gutter:false] $tempo->parse('eRoot', 'templates/tempo.sample.htm'); [/code]
parse_str(string $template_handle, string $template_string)
문자열 형식의 템플릿 문서를 파싱해 줍니다. 첫번째 인수는 parse() 멤버함수의 경우와 동일하며, 두번째 인수는 템플릿 문서를 문자열 형식으로 직접 지정해 줍니다.
[code php;gutter:false] $tempo->parse_str('eRoot', '<p>[[[ <?=$TEMPO_VAR?> ]]]</p>'); [/code]
예를 들면:
[code php;gutter:false] <?php require_once('class.Tempo.php'); $tempo = new Tempo; $tempo->parse('eRoot', '<p>[[[ <$TEMPO_VAR/> ]]]</p>'); [/code]
< PHP coding >
블록요소를 다루는 멤버함수
assign([string $operator])
이 멤버함수를 실행하게 되면 블록요소 내용에 포함된 모든 PHP 코드가 평가되어 그 결과를 멤버변수 innerHTML에 저장합니다.
[code php;gutter:false] $tempo->parse('eRoot', $template_contents); $tempo->el['eRoot']->assign(); [/code]
< PHP coding >
멤버함수 assign()의 첫번째 인수는 할당하는 방법을 나타내는 것으로 빈문자열, '=', 또는 '.'를 지정할 수 있습니다. 생략하게 되면 '='를 지정한 것과 같습니다. 빈문자열을 지정하면 멤버변수 innerHTML의 내용을 삭제합니다. '='를 지정하면 멤버 변수 innerHTML의 내용을 삭제한 후 블록요소를 평가합니다. '.'를 지정하면 평가한 결과를 innerHTML의 기록되어 있는 기존의 내용에 덧붙이게 됩니다.
[code php;gutter:false] $tempo->el['eLoop']->assign(''); for ($i=0; $i<3; $i++) { $tempo->el['eLoop']->assign('.'); } $tempo->el['eRoot']->assign('='); [/code]
output()
블록요소의 멤버변수 innerHTML의 내용을 분석하여 내용을 재분류한 후 내부버퍼에 저장한 후 스크립트가 종료할 때 출력해줍니다.
[code php;gutter:false] $tempo->parse('eRoot', $template_contents); $tempo->el['eRoot']->assign(); $tempo->el['eRoot']->output(); [/code]

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}6.다운로드  (0) 2008.07.16
{템포2}5.다이나믹블록  (0) 2008.07.16
{템포2}3.템플릿 문서  (0) 2008.07.16
{템포2}2.기초다지기  (0) 2008.07.16
{템포2}1.소개  (0) 2008.07.16
Posted by 방글24
phpsource/템플릿2008. 7. 16. 01:08
written: 2008.07.15
last modified: 2008.07.22
템플릿 변수
템포2에서 제공하는 템플릿 변수 태그는 없습니다. PHP 태그를 이용하여 이 기능을 수행합니다.
[code html;gutter:false] <p>[[[ <?=$TEMPO_VAR?> ]]]</p> [/code]
< Template file : tempo.sample.htm >
[code php;gutter:false] <?php require_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('sample', 'tempo.sample.htm'); $TEMPO_VAR = 'The value assigned by PHP global variable'; $tempo->el['sample']->assign(); $tempo->el['sample']->output(); ?> [/code]
< PHP coding >
[code html;gutter:false] <p>[[[ The value assigned by PHP global variable ]]]</p> [/code]
< Result >
다이나믹 블록 요소(Dynamic Block Element)
다이나믹 블록은 정적인 템플릿 문서의 내용을 동적으로 할당할 수 있도록 해 줍니다. 템플릿 문서를 템포2에 의해 파싱하게 되면 모든 다이나믹 블록 요소가 독립적인 객체로 존재하게 되며 각 블록 요소의 객체를 통해 블록 요소의 내용을 동적으로 변경하여 할당할 수 있습니다. 블록 요소의 태그는 <tempo id="블록요소명" 속성>블록요소내용</tempo>와 같은 형식을 가지고 있습니다.
[code html;gutter:false] <table> <tr> <th>classify</th> <th>column1</th> <th>column2</th> <th>column3</th> </tr> <tempo id="eLoop"> <tr> <td><?=$column0?></td> <td><?=$column1?></td> <td><?=$column2?></td> <td><?=$column3?></td> </tr> </tempo> </table> [/code]
< Template contents >
<tempo id="블록요소명" 속성>블록요소내용</tempo> 대신에 <@블록요소명 속성>블록요소내용</@>와 같은 축약된 형식을 사용할 수 있습니다. 만약 블록요소내용이 필요하지 않는 경우에는 <tempo id="블록요소명" 속성 /> 또는 <@블록요소명 속성 />와 같은 형식을 사용할 수도 있습니다.
템포2 속성(TEMPO2 attribute statements)
템포2에서 지정할 수 있는 속성에는 'id', 'src', 'selected', 'display', 'ctype'이 있습니다.
  • id - 블록요소명
  • selected - 자동 할당을 선택하는 속성
  • display - 블록요소의 출력유무 선택
  • ctype - 블록 문서의 형식을 지정
  • src - 인클루드할 파일명 지정
  • switch - 각 경우의수를 선택할 스위치 변수 지정 (0.0.1-beta2 추가)
속성은 속성명과 속성값으로 구성되어 있으며, 속성값은 필요한 경우에만 설정하며, 설정하더라도 변수(PHP 코드)는 포함할 수 없습니다.
속성 id
속성 id는 블록요소명을 지정할 때 사용하며, 또한 파싱후 다루게 될 각 블록요소에 해당하는 객체를 다루는 블록 핸들로도 사용됩니다. 따라서 하나의 실행 스크립트 문서 내에서 중복될 수 없는 유일한 이름이어야 합니다. 예를들면,
[code html;gutter:false] <tempo id="eLoop"> ... </tempo> [/code]
속성 selected
템포2는 배열형식의 변수값에 의해 블록요소가 자동으로 할당되지 않습니다. 부모 블록요소를 할당하기 전에 반드시 자식 블록요소를 먼저 할당해야 합니다. 자식 블록요소를 먼저 할당하지 않고 부모 블록요소를 할당하면 자식 블록요소 부분에 아무 것도 나타나지 않습니다.
[code html;gutter:false] <table> <tr> <th>column1</th> <th>column2</th> <th>column3</th> </tr> <tempo id="eLoop"> <tr> <td><?=$column1?></td> <td><?=$column2?></td> <td><?=$column3?></td> </tr> </tempo> </table> [/code]
< Template contents >
블록요소 'eLoop'를 할당하지 않고 템플릿 문서를 할당하여 출력하면 아래와 같이 블록요소 'eLoop'는 나타나지 않습니다.
[code html;gutter:false] <table> <tr> <th>column1</th> <th>column2</th> <th>column3</th> </tr> </table> [/code]
만약 자식 블록요소 'eLoop'를 사용자가 할당하지 않고 템포2 내에서 자동 할당하려면 속성 selected를 지정합니다. 이 속성은 속성명만 가지며 속성값을 필요로 하지 않습니다.
[code html;gutter:false] <tempo selected> ... </tempo> [/code]
속성 display
display 속성값을 'none'로 설정하면 블록요소를 출력하지 않습니다. selected 속성이 동시에 지정되어 있더라도 출력되지 않습니다.
[code html;gutter:false] <tempo display="none"> ... </tempo> [/code]
속성 ctype
[code html;gutter:false] <table border=1> <tr> <th>ctype</th><th>result</th> </tr> <tr> <td>default</td><td> <tempo selected> <span style="color:red;"><?=$VAR?></span> </tempo> </td> </tr> <tr> <td>text</td><td> <tempo ctype="text" selected> <span style="color:red;"><?=$VAR?></span> </tempo> </td> </tr> <tr> <td>html</td><td> <tempo ctype="html" selected> <span style="color:red;"><?=$VAR?></span> </tempo> </td> </tr> <tr> <td>php</td><td> <tempo ctype="php" selected> <span style="color:red;"><?=$VAR?></span> </tempo> </td> </tr> </table> [/code]
< Template contents : tempo.sample.htm >
[code php;gutter:false] <?php require_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('sample', 'tempo.sample.htm'); $VAR = 'apple'; $tempo->el['sample']->assign(); $tempo->el['sample']->output(); ?> [/code]
< PHP coding >
ctype result
default apple
text <span style="color:red;"><?=$VAR?></span>
html <?=$VAR?>
php <span style="color:red;">apple</span>
속성 src
인클루드할 파일명을 지정할 때 사용하는 속성으로 src 속성을 포함하고 있는 템플릿 문서를 기준으로하는 상대경로를 지정합니다.
[code html;gutter:false] <p><tempo src="sub/sample.htm" /></p> [/code]
만약 상대경로가 아닌 절대경로로 지정하려면 '/'로 시작하는 웹서버 루트를 기준으로 지정합니다.
[code html;gutter:false] <p><tempo src="/home/templates/sub/sample.htm" /></p> [/code]
scr 속성을 갖는 블록요소는 selected 속성을 지정하지 않아도 자동 할당됩니다.
src 속성을 사용하는 예를 들면,
[code html;gutter:false] [[[ <?=$TEMPO_VAR?> ]]] [/code]
< Template file : tempo.sub.htm >
[code php;gutter:false] <p><tempo src="tempo.sub.htm" /></p> [/code]
< Template file : tempo.main.htm >
[code php;gutter:false] <?php require_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('eRoot', 'tempo.main.htm'); $TEMPO_VAR = "The value assigned by PHP global variable"; $tempo->el['eRoot']->assign(); $tempo->el['eRoot']->output(); ?> [/code]
< PHP coding >
[code html;gutter:false] <p>[[[ The value assigned by PHP global variable ]]]</p> [/code]
< Result >
속성 switch
PHP 문서에서 아래와 같은 스위치문을 많이 보셨을 것입니다.
[code php;gutter:false] <?php switch ($var_name) { case 'apple': print '나는 사과입니다.'; break; case 'pear': print '나는 배입니다.'; break; case 'orange': print '나는 오렌지입니다.'; break; } ?> [/code]
switch 속성을 이용하면 아래와 같이 같은 기능을 수행하는 템플릿 문서를 작성할 수 있습니다.
[code html;gutter:false] <tempo switch="$var_name"> %apple% 나는 사과입니다. | %pear% 나는 배입니다. | %orange% 나는 오렌지입니다. </tempo> [/code]
< tempo.sample.htm >
PHP 스크립트 문서에서 switch 속성을 갖는 다이나믹 블록의 상위 블록요소를 할당하기 전에 전역변수 $var_name의 값을 아래와 같이 지정하면 됩니다.
[code php;gutter:false] <?php require_once('class.Tempo2.php'); $tempo = &new Tempo2; $tempo->parse('sample', 'tempo.sample.htm'); $var_name = 'pear'; $tempo->el['sample']->assign(); $tempo->el['sample']->output(); ?> [/code]
src 속성과 마찬가지로 switch 속성을 갖는 블록요소는 selected 속성을 지정하지 않아도 스위치 변수의 값에 의해 해당 항목이 자동 할당됩니다.
아래와 같이 속성명 switch를 생략한 채 스위치 변수명 $var_name 만으로 된 축약된 형식으로 나타낼 수 있습니다.
[code html;gutter:false] <@$var_name> %apple% 나는 사과입니다. | %pear% 나는 배입니다. | %orange% 나는 오렌지입니다. </@> [/code]
switch 속성을 갖는 블록요소에 블록요소명(id)을 지정할 때는 축약된 형식을 사용할 수 없으며 반드시 아래와 같이 축약되지 않은 형식을 사용하여야 합니다.
[code html;gutter:false] <tempo id="SWITCH_TEST" switch="$var_name"> %apple% 나는 사과입니다. | %pear% 나는 배입니다. | %orange% 나는 오렌지입니다. </tempo> [/code]
인덱스키는 생략할 수 있으며 생략하게 되면 앞에서부터 1, 2, 3, 4, 5가 자동으로 지정됩니다.
[code html;gutter:false] <tempo switch="$var_name"> 첫번째값 | 두번째값 | 세번째값 | 네번째값 | 다섯번째값 </tempo> [/code]
조건에 맞는 항목이 없을 때는 아무런 값도 출력하지 않습니다. 그러나 예약어 'default' 라는 인덱스키로 지정된 항목을 작성하면 조건에 맞는 항목이 없을 때 default로 지정된 항목을 출력할 수 있습니다.
[code html;gutter:false] <tempo switch="$var_name"> 첫번째값 | 두번째값 | 세번째값 | 네번째값 | %default% 기본값 </tempo> [/code]
위의 예제의 경우에 PHP에서 전역 변수 $var_name에 0과 같은 1, 2, 3, 4 이외의 값을 할당한다면 default로 지정된 항목 "기본값"이 출력됩니다.
만약 아래의 경우와 같이 중간에 있는 항목에만 인덱스키를 지정한 경우를 살펴보겠습니다.
[code html;gutter:false] <tempo switch="$var_name"> 첫번째값 | 두번째값 | %mid% 중간값 | 네번째값 | %default% 기본값 </tempo> [/code]
각 경우에 지정된 인텍스키를 보면 앞에서부터 1, 2, 'mid', 4, 'default'입니다.
템플릿 문서에서 인덱스키가 숫자로만 구성되어 있으면 정수로 인식하며, 기타의 경우는 모두 문자열로 인식합니다. 따라서 스위치 변수에 값을 지정할 때 숫자로만 구성된 인덱스키를 문자열로 지정할 수 없으며 반드시 정수값으로 지정하여야 합니다.
switch 속성을 갖는 블록요소도 다른 블록요소와 동일하게 처리하기 때문에 제한없이 모든 속성의 다이나믹 블록과 함께 중첩할 수 있습니다.
※ switch 속성은 0.0.1-beta2 버전부터 사용할 수 있습니다.
URL 리디렉션(URL redirection)
템플릿 문서 내에 존재하는 그림이나 동영상과 같은 리소스의 경로는 현 템플릿 문서 위치를 기준으로 작성됩니다. 이와같이 현 템플릿 문서를 기준으로 작성된, 즉 상대경로를 지정된 파일들의 경로를 현재 실행중인 PHP 문서 기준으로 리디렉션하여 줍니다. 확장자가 htm, html, css, js, gif, jpg, jpeg, png, swf, php, php3인 파일이 리디렉션하려는 경로에 실제로 존재할 때 리디렉션해줍니다.
※ php, php3 확장자는 0.0.1-beta2 버전부터 사용할 수 있습니다.
기타 다른 확장자를 가진 파일이나 디렉토리를 리디렉션하려면 블록요소객체의 멤버인 pathTPL 변수를 이용합니다. pathTPL 멤버변수에는 현 템플릿 파일문서의 경로가 저장되어 있습니다.
[code html;gutter:false] <p> <tempo> <img src="<?=$this->pathTPL?>/images/logo.gif"> </tempo> </p> [/code]

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}5.다이나믹블록  (0) 2008.07.16
{템포2}4.멤버함수  (0) 2008.07.16
{템포2}2.기초다지기  (0) 2008.07.16
{템포2}1.소개  (0) 2008.07.16
{후키템플릿}8.1.필터 기능  (0) 2008.05.31
Posted by 방글24
phpsource/템플릿2008. 7. 16. 01:07
written: Jul 15 2008
템포2 사용방법
아래와 같은 순서를 통해 템포2를 사용할 수 있습니다.
  1. 템플릿 문서 준비하기
  2. 템포2 클래스 파일 인클루드하기
  3. 클래스의 객체 생성하기
  4. 템플릿 문서를 파싱(parse)하기
  5. 변수 할당하기
  6. 블록요소 할당(assign)하기
  7. 할당된 템플릿 문서를 출력(output)하기
1. 템플릿 문서 준비하기
템플릿 문서(파일 또는 문자열)는 기본적으로 HTML 문서로  변수와 다이나믹 블록을 포함하고 있습니다. 변수는 별도의 변수형식을 제공하지 않으며 PHP에서 제공하는 <?=$변수명?>이 같은 형식을 그대로 이용합니다. 다이나믹 블록은 <tempo id="블록요소명" 속성>블록요소내용</tempo>와 같은 형식의 태그를 이용하여 템플릿 문서를 작성합니다.
[code html;gutter:false] <table> <tr> <th>column1</th> <th>column2</th> <th>column3</th> </tr> <tempo id="eLoop"> <tr> <td><?=$column1?></td> <td><?=$column2?></td> <td><?=$column3?></td> </tr> </tempo> </table> [/code]
2. 템포2 클래스 인클루드하기
가장 먼저 템포2 클래스 파일(class.tempo2.php)를 require_once() 또는 include_once()를 이용하여 인클루드합니다.
[code php;gutter:false] require_once('somewhere/class.Tempo2.php'); [/code]
3. 클래스의 객체 생성하기
new 연산자를 사용하여 템포2 클래스의 객체를 생성화합니다. PHP4 버전에서는 반드시 참조연산자(&)를 사용하여야 합니다.
[code php;gutter:false] $tempo = &new Tempo2; [/code]
4. 템플릿 문서를 파싱(parse)하기
템플릿 문서(파일 또는 문자열)를 parse() 또는 parse_str() 메쏘드를 사용하여 파싱합니다. 첫번째 인수는 템플릿 핸들이고 두번째 인수는 템플릿 문서(파일명 또는 문자열)를 지정합니다.
[code php;gutter:false] $tempo->parse('eRoot', 'templates/tempo.sample.htm'); [/code]
템플릿 문서를 파싱할 때 문서 내에 포함된 다이나믹 블록요소들은 별도의 객체로 생성됩니다. 각 블록요소 객체는 블록요소명을 키로 하는  el 멤버를 통해 접근할 수 있습니다. 템플릿 문서도 최상위 블록요소로 취급되며 최상위 블록요소명는 parse() 메쏘드의 첫번째 인수로 지정된 템플릿 핸들이 됩니다. 템플릿 핸들 'eRoot'와  블록요소명 'eLoop'에 해당하는 각 객체를 접근하기 위한 예를 들어보면 아래와 같습니다.
[code php;gutter:false] $tempo->el['eRoot']->innerTPL; $tempo->el['eLoop']->innerTPL; [/code]
5. 변수 할당하기
PHP의 전역변수를 이용하여 그 값을 할당합니다.
[code php;gutter:false] $column1 = 'apple'; $column2 = 'banana'; $column3 = 'orange'; [/code]
6. 블록요소 할당(assign)하기
최상위 블록요소인 템플릿 문서를 포함한 모든 블록요소에 해당하는 객체를 통해 블록요소 내용을 할당합니다.
[code php;gutter:false] $tempo->el['eLoop']->assign(''); for ($i=0; $i<3; $i++) { $tempo->el['eLoop']->assign('.'); } $tempo->el['eRoot']->assign(); [/code]
7. 할당된 문서를 출력(output)하기
템플릿 문서를 할당할 때와 마찬가지로 블록단위로 출력하게 됩니다.
[code php;gutter:false] $tempo->el['eRoot']->output(); [/code]

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}4.멤버함수  (0) 2008.07.16
{템포2}3.템플릿 문서  (0) 2008.07.16
{템포2}1.소개  (0) 2008.07.16
{후키템플릿}8.1.필터 기능  (0) 2008.05.31
{Tempo}6.Download  (0) 2007.09.01
Posted by 방글24
phpsource/템플릿2008. 7. 16. 01:06
written: Jul 15 2008
목차
템포2(TEMPO2)의 기능
템포2(TEMPO2)는 "TEMPlate Object 2"의 머리글자에서 얻은 명칭으로 PHP용 템플릿 엔진입니다. 이전에 공개한 템포와는 전혀 다른 템플릿 형식을 갖춘 것으로 이전 템포보다 형식을 더 단순화시켰으며 아울러 후키템플릿 문서를 포팅하기 편하도록(?) 구성되어 있습니다. 템포2는 다른 템플릿툴과 달리 변수에 대한 별도의 태그를 제공하지 않고 다이나믹 블록에 대한 태그만 제공합니다. 변수 기능이 필요할 때는 PHP에서 제공하는 <?=$변수명?>와 같이 PHP 문법을 이용하면 됩니다.
[code html;gutter:false] <p>Hello <?=$name?>. How are you?</p> [/code]
다이나믹 블록 태그의 형식은 <tempo id="블록요소명" 속성>블록요소내용</tempo>와 같습니다.
[code html;gutter:false] <table> <tr> <th>column1</th> <th>column2</th> <th>column3</th> </tr> <tempo id="eLoop"> <tr> <td><?=$column1?></td> <td><?=$column2?></td> <td><?=$column3?></td> </tr> </tempo> </table> [/code]
각 블록요소를 구분하는 id로 지정된 블록요소명은 현재 실행되고 있는 스크립트 문서에서 유일한 이름이어야 합니다.
설치(Installation)
템포2 클래스 파일(class.Tempo2.php)을 사용자가 원하는 임의의 장소(somewhere)에 복사한 후 스크립트 내에서 템포2 클래스 파일을 require_once 또는 include_once 명령으로 포함시킵니다.
[code php;gutter:false] <?php require_once('somewhere/class.Tempo2.php'); [/code]
라이센스(License)
hwooky's tempo2(template object 2) is licensed using LGPL.
Copyright (c) 2006-2008 Wookyung Hwang(hwooky@phpclass.com).
All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

-GNU LESSER GENERAL PUBLIC LICENSE (LGPL)

Address Bug Reports or Comments on THIS LIBRARY ONLY to
Wookyung Hwang, hwooky@phpclass.com
The latest version of this class should be available from the following locations:
http://tempo.phpclass.com

For more info about hwooky's tempo2(template object 2),
visit www.phpclass.com

'phpsource > 템플릿' 카테고리의 다른 글

{템포2}3.템플릿 문서  (0) 2008.07.16
{템포2}2.기초다지기  (0) 2008.07.16
{후키템플릿}8.1.필터 기능  (0) 2008.05.31
{Tempo}6.Download  (0) 2007.09.01
{Tempo}5.Example - Repeat Block  (0) 2007.09.01
Posted by 방글24