buggedcom / customtags
允许您创建HTML自定义标签,这些标签有助于模板制作,并提供易于使用的可扩展功能,使设计师能够轻松工作。
dev-master
2015-05-02 12:10 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-23 14:19:33 UTC
README
#PHP 自定义标签
允许您创建HTML自定义标签,这些标签有助于模板制作,并提供易于使用的可扩展功能,使设计师能够轻松工作。创建完全可定制的标签,并且还附带了一个简单的内部模板引擎。
标签还可以批量收集和处理,这在优化数据库查询和其他类似操作的性能时非常有用。
##一个示例自定义标签。
<ct:inline some="attribute"> This is an in line template. <br /> This is a #{tag} that can be accessed by the callback function </ct:inline>`
##简单的集成示例
<?php $current_dir = dirname(__FILE__).DIRECTORY_SEPARATOR; require_once dirname($current_dir).DIRECTORY_SEPARATOR.'customtags.php'; $ct = new CustomTags(array( 'parse_on_shutdown' => true, 'tag_directory' => $current_dir.'tags'.DIRECTORY_SEPARATOR, 'sniff_for_buried_tags' => true )); ?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>untitled</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Oliver Lillie"> <!-- Date: 2010-07-10 --> </head> <body> <ct:youtube id="wfI0Z6YJhL0" /> </body> </html>
在相关标签文件中;tags/youtube/tag.php
<?php function ct_youtube($tag) { return '<object id="'.$tag['attributes']->id.'" value="http://www.youtube.com/v/'.$tag['attributes']->id.'" /><param ...etc...>'; }
输出结果
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>untitled</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Oliver Lillie"> <!-- Date: 2010-07-10 --> </head> <body> <object id="wfI0Z6YJhL0" value="http://www.youtube.com/v/wfI0Z6YJhL0" /><param ...etc...> </body> </html>