ASP has two types of scripts: VBScript and JScript. They all contain a "RegExp object" (RegExp). Using string objects and RegExp objects, you can easily implement the template function. Mu Feng wrote a "Template. JScript. INC" file. The content of this file is attached to the end of the article. Competent readers can make improvements based on their own needs.
The following describes how to use it. Because this file is written in JScript (of course, it is easy to convert it to VBScript), the de
PHP has a template program (fasttemplate), the problem now is how to implement similar functions in ASP.Microsoft's ASP comes with two kinds of scripts: VBScript and JScript. They all carry a "regular Expression object" (REGEXP) that makes it easy to implement template functionality with string objects and RegExp objects. Mu Maple to write a "Template.JScript.INC" file, the contents of this file attached to the post. The ability of the reader can be based on their own needs to improve.
Here's
ASP has two types of scripts: VBScript and JScript. They all contain a "Regexp object" (Regexp). Using string objects and Regexp objects, you can easily implement the template function. Mu Feng wrote a "template. JScript. Inc" file. The content of this file is attached to the end of the article. Competent readers can make improvements based on their own needs.
The following describes how to use it. Because this file is written in JScript (of course, it is easy to convert it to VBScript), the de
efficient when writing sites that support multiple languages, such as using echo and print to visualize the workload. Do not worry, skilled use of fasttemplate will take up part of your time, but these times will be in your future work to make up for back, especially when the big project. So, how do you use Fasttemplate? The first step is simply to use the function
, where path points to the path where the template directory resides. This function establishes a $
specified location (if scientific counts are e;)
%, when there is a format flag in the string, a percent sign is required
?
1234567891011
tpl = "i am %s" % "alex"tpl = "i am %s age %d" % ("alex", 18)tpl = "i am %(name)s age %(age)d" % {"name": "alex", "age": 18}tpl = "percent %.2f" % 99.97623
-adjust convert integers, floating-point numbers to floating-point or scientific notation (more than 6 digits in scientific notation), and format them to a specified location (if scientific counts are e;)
G, auto-adjust convert integers, floating-point numbers to floating-point or scientific notation (more than 6 digits in scientific notation), and format them to a specified location (if scientific counts are e;)
%, when there is a format flag in the string, a percent sign is required
Originally want to arttemplate source analysis of the comments put up to share, but after a year, can not find, had to analyze the template engine principles, their own try
Write down the template engine to share with you, leave a souvenir, remember also compared to several template engine.
Here is the JS template engine, with the native JavaScript syntax, so very similar to PHP's native template engine.
What is the role of the front-end template engine?
1. Can make front-end development s
Copy CodeThe code is as follows:
Class Lightpage_template {
var $Tpl _header;
var $Tpl _footer;
var $Tpl _parsing;
var $Tpl _template;
var $Tpl _dirname;
var $Tpl _parse_string;
var $Tpl
PHP question [urgent] [urgent] [urgent] [urgent] Please help me with template assignment
The final page code is as follows:
Assign ("show", 'success '); $ show = '000000'; include ('Templates/index.html '); ==================================== if you write this code in this way, $ show can be assigned a value // include ('F: /AppServ/www/temp/tpl/com_index.html.php '); // $ tpl-> compile('index.html ');
$TPL =new Smarty ()//New Smarty object, I'm using the Smarty-3.1.6 version1. Set smarty template path $tpl->settemplatedir (); By default, templates2. Set the Smarty template compilation path $tpl->setcompiledir (); By default, Templates_c3. Set the left and right delimiters of the Smarty template engine,
$tpl->left_d
displaying the template referenced by the Smarty enginePrototype: var display (string template[,string cache_id][,string compile_id])Parameter one: template is required and specifies the type and path of a legitimate template resourceParameter two: cache_id specifies the name of a cache identifierParameter three: COMPILE_ID used when maintaining multiple caches on a pageUse the following method$smarty->display (' tpl/template_dir/template.html ');Sim
Smarty scripts and can only be used once in a script, which is responsible for obtaining and displaying templates referenced by the Smarty engine
Prototype: var display (string template[,string cache_id][,string compile_id])
Parameter one: template is required, specifies the type and path of a legitimate template resource
Parameter two: cache_id specifies the name of a cached identifier
Parameter three: COMPILE_ID is used when maintaining multiple caches on a page
Use the following methods
$TPL =new Smarty ()//New Smarty object, I'm using the Smarty-3.1.6 version
1. Set Smarty template path $tpl->settemplatedir (); By default, templates
2. Set the Smarty template compilation Path $tpl->setcompiledir (); By default, Templates_c
3. Set the left and right delimiters of the Smarty template engine,
The code is as follows
Copy Code
$TPL =new Smarty ()//New Smarty object, I'm using the Smarty-3.1.6 version
1. Set Smarty template path $tpl->settemplatedir (); By default, templates
2. Set the Smarty template compilation Path $tpl->setcompiledir (); By default, Templates_c
3. Set the left and right delimiters of the Smarty template engine,
The code is as follows
Copy Code
(fasttemplate), the problem now is how to implement similar functions in ASP.
Microsoft's ASP comes with two kinds of scripts: VBScript and JScript. They all carry a "regular Expression object" (REGEXP) that makes it easy to implement template functionality with string objects and RegExp objects. Mu Maple to write a "Template.JScript.INC" file, the contents of this file attached to the post. The ability of the reader can be based on their own needs to improve.
Here's how to use this. Because th
Smarty delimiter here$smarty->assign (' name ', ' value ');The PHP statement block cannot be executed in the call template TPL file$smarty->display (' Templates/index.tpl ');/*Smarty compile-time processing is the source PHP file, template file (may call multiple or more than one), source PHP file ...This means that the original PHP file is not affected by other processing and output. So the Smarty template file can be either full HTML or part of it.
notation (more than 6 digits in scientific notation), and format them to a specified location (if scientific counts are e;)
%, when there is a format flag in the string, a percent sign is required
Common formatting:TPL ="I am%s"%"Alex"TPL="I am%s age%d"% ("Alex", -) TPL="I am% (name) s age percent (age) D"% {"name":"Alex"," Age": -} TPL="percent%.2f"%99
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.