', ' Wangwu ') #如果只有大括号, then match the content in format from the previous Zhangshan Lisi Wangwu Attached 1: progress bar (yum style), need to run in terminal to show, do not know what GhostStart = 0total = #需要接受的数据的总数 while start Attachment 2: ExercisesTPL = "I am {}, age {}, {}". Format ("Seven", ' Alex ') TPL = "I am {}, age {}, {}". Format (*["Seven", "Alex"])
engine named tmd_tpl,
Although it may not be powerful yet, it is a necessity for the future.
· Tmd _ tpl getting started tutorial:
Next we will learn how to use tmd_tpl. The process is no different from other template engines.
I. initialize the template engine
The code is as follows:
// Include tmd_tplRequire '../tmdphp/tmd_tpl.php'; // change it to the path of your tmd_tpl.// Instantiate tmd_tpl$ TPL
[PHP]View Plaincopy
Class myminismarty{
//template file storage path
var $template _dir="./templates/";
//Compile file, the name format of the compiled file is tentatively: Com_ corresponding tpl.php
var $complie _dir="./templates_c";
//Template variable array: Store values for all template variables
var $tpl _vars=Array ();
//Here we mainly simulate two methods
//Parameter 1-template variable parameter 2: value of templat
By coldwind/iwind/month/ccterran http://iwind.org
For a long time, I asked people around how to implement static Web pages and asked questions. Now, I finally come up with a very simple solution, that is, using libtemplate to implement it.
Look: http://doc.iwind.org
Next I will talk about how to implement static webpage output.
1. Modify libtemplate.
Add two functions
// Save the analysis result to a file
Function savetofile ($ Dir, $ varname ){
$ DATA = $ this-> finish ($ this-> get_var ($ varn
The role of the configuration file in the template is to define variables for the front-end design page, which mainly controls the appearance of the template and has nothing to do with the PHP program.
Procedure:
1. Use $ tpl-> configs_dir = "directory" // specify the directory where the configuration file is stored;
2. Use
The purpose of setting a region is to call the configuration file variables of different regions for different files.
In the con
percentages (6 digits after the decimal point by default)
Common formatting:TPL ="I am {}, age {}, {}". Format ("Seven", 18,'Alex') TPL="I am {}, age {}, {}". Format (*["Seven", 18,'Alex']) TPL="I am {0}, age {1}, really {0}". Format ("Seven", 18) TPL="I am {0}, age {1}, really {0}". Format (*["Seven", 18]) TPL="
By coldwind/iwind/month/ccterran http://iwind.orgFor a long time, I asked people around how to implement static Web pages and asked questions. Now, I finally come up with a very simple solution, that is, using libtemplate to implement it.Look: http://doc.iwind.orgNext I will talk about how to implement static webpage output.1. Modify libtemplate.Add two functions// Save the analysis result to a fileFunction savetofile ($ dir, $ varname ){$ Data = $ this-> finish ($ this-> get_var ($ varname ));$
First, use the method of%s.#!/usr/bin/env python#Coding:utf-8#use%s and%d without the format methodname='Tom' Age= 100msg="%s is a good man, you can live to be%d years old."% (Name,age)#%d can only pass numbers, so it is most convenient to use%sPrint(msg)#Interception of Stringstitle ="the average price of the provinces in the country has risen 30%"Ms="The important news today is:%.9s"% title#intercept 9 bits, which can be used to control the lengthPrint(MS)#Print floating-point numbersTPL ="I g
This article mainly introduces JavaScript input mailbox automatic Prompt instance code, need friends can refer to the Originally wanted 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 attempt to nbsp; write the template engine to share with you, leave a souvenir, remember at that time also contrasted several template engine. nbsp; Here is the JS template engine, with native JavaScript synta
properties of the Smarty class and is named Main.php, saved in the Smarty directory, and which script needs to use Smarty in the future, we just include the main.php.
12345678910111213
?Include ("./smarty/libs/smarty.class.php");Define (' Smarty_root ', './smarty/tpls ');$TPL = new Smarty ();$tpl->template_dir = smarty_root. " /templates/";$tpl-
/** Function: pagination of the content list* Time: 2006-2-21* Author: Happy with the wind* Others: modification to purely misunderstanding Google's paging Program** Parameters:* $ Table Name, required* $ Where query condition, optional* $ Pagesize information quantity, optional* $ Number of midpage navigation links, optional** Global variables:* $ Conn database operation object* $ TPL template to operate on objects* $ Start returns the start subscrip
Ha, for a long time do not write a blog, today casually write a point, how this blog editor has become a FCK?Sudden inspiration, wrote a very simple template class, although there is no advanced things, but I always think that inspiration also need to accumulate.Kong. Template class file code:/*** Author: darasion* Copyright: Use or reprint to indicate the author**/Class darasiontemplate{
var $template = "";var $VAR = array ();var $className = "Darasiontemplate";
/*** Set parameters/Templates**/
In this paper, the use of filters for Smarty advanced Features is analyzed. Share to everyone for your reference, as follows:
Use of filters in advanced features
1. Pre-Filter
function remove_dw_comments ($tpl _source, $smarty) {return preg_replace ("/
U", "", $tpl _source);// Remove the annotations in the original TPL file so that they do not display the}
very simple. The method is to obtain the analysis results and write the analysis results into a file. The following uses template. Inc in phplib to talk about generating static webpages using templates.
1. modify template. Inc.Add the following functions:// Save the analysis result to a fileFunction savetofile ($ Dir, $ varname ){$ DATA = $ this-> finish ($ this-> get_var ($ varname ));$ Fp = fopen ($ Dir, "W + ");Fwrite ($ FP, $ data );}// Clear the assigned ArrayFunction renew (){$ This-> var
Simple Smarty for beginners to understand smarty help from itcast Hanshunping teacher Smarty 2nd, 3 speak
Class myminismarty{
Public $template _dir = "./templates";
Public $complie _dir = "./templates_c";
Public $tpl _vars = Array ();
Public Function assign ($tpl _var, $val = NULL) {
if (!empty ($tpl _
In the template design section of smarty, I briefly introduced some common settings of smarty in the template. This section mainly introduces How to Start program design in smarty.First, we will introduce some elements in the. Php file we used in the previous section. Similarly, let's take the index. Php file at the beginning of the previous section as an example:========================================================== ==========Index. php===================================================
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.