亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

annuaire recherche
Smarty模板編譯引擎 I.開始 第一章. 什么是Smarty? 第二章. 安裝 要求 基本安裝 擴(kuò)展設(shè)置 II.模板設(shè)計(jì)者篇 第三章.基本語法 注釋 函數(shù) 屬性 第四章.變量 從PHP分配的變量 Associative arrays Array indexes Objects 從配置文件讀取的變量 {$smarty}保留變量 Request variables {$smarty.now} {$smarty.const} {$smarty.capture} {$smarty.config} {$smarty.section} {$smarty.template} 第五章.變量調(diào)節(jié)器 capitalize count_characters cat count_paragraphs count_sentences count_words date_format default escape indent lower nl2br regex_replace replace spacify string_format strip strip_tags truncate upper wordwrap 第六章.組合修改器 第七章.內(nèi)建函數(shù) capture config_load foreach include include_php insert if ldelim literal php section index index_prev index_next iteration first last rownum loop show total strip 第八章.自定義函數(shù) assign counter cycle debug eval fetch html_checkboxes html_image html_options html_radios html_select_date html_select_time html_table math mailto popup_init popup textformat 第九章.配置文件 第十章.調(diào)試控制臺(tái) III.模板程序員篇 第十一章 常量 SMARTY_DIR 第十二章 變量 $template_dir $compile_dir $config_dir $plugins_dir $debugging $debug_tpl $debugging_ctrl $global_assign $undefined $autoload_filters $compile_check $force_compile $caching $cache_dir $cache_lifetime $cache_handler_func $cache_modified_check $config_overwrite $config_booleanize $config_read_hidden $config_fix_newlines $default_template_handler_func $php_handling $security $secure_dir $security_settings $trusted_dir $left_delimiter $right_delimiter $compiler_class $request_vars_order $compile_id $use_sub_dirs $default_modifiers $default_resource_type 第十三章.方法 append append_by_ref assign assign_by_ref clear_all_assign clear_all_cache clear_assign clear_cache clear_compiled_tpl clear_config config_load display fetch get_config_vars get_registered_object get_template_vars is_cached load_filter register_block register_compiler_function register_function register_modifier register_object register_outputfilter register_postfilter register_prefilter register_resource trigger_error template_exists unregister_block unregister_compiler_function unregister_function unregister_modifier unregister_object unregister_outputfilter unregister_postfilter unregister_prefilter unregister_resource 第十四章.緩存 Setting Up Caching Multiple Caches Per Page Cache Groups Controlling Cacheability of Plugins' Output 第十五章.高級(jí)特點(diǎn) Objects Prefilters Postfilters Output Filters Cache Handler Function Resources Templates from $template_dir Templates from any directory Templates from other sources Default template handler function 第十六章.以插件擴(kuò)展Smarty How Plugins Work Naming Conventions Writing Plugins Template Functions Modifiers Block Functions Compiler Functions Prefilters/Postfilters Output Filters Resources Inserts Ⅳ.高級(jí)特點(diǎn) 第十七章.疑難解答 Smarty/PHP errors 第18章.使用技巧和經(jīng)驗(yàn) Blank Variable Handling Default Variable Handling Passing variable title to header template Dates WAP/WML Componentized Templates Obfuscating E-mail Addresses 第十九章. 相關(guān)資源 第二十章. 漏洞
personnages

Preface[序]

It is undoubtedly one of the most asked questions on the PHP mailing lists: how do I make my PHP scripts independent of the layout? While PHP is billed as "HTML embedded scripting language", after writing a couple of projects that mixed PHP and HTML freely one comes up with the idea that separation of form and content is a Good Thing [TM]. In addition, in many companies the roles of layout designer and programmer are separate. Consequently, the search for a templating solution ensues.

該如何使我的PHP腳本從設(shè)計(jì)中獨(dú)立出來?這無疑地是在 PHP 郵件列表上所提問的最多的問題之一。雖然 PHP 被標(biāo)榜為 "HTML 嵌入式語言", 在寫過許多php和html混合式的工程之后,我產(chǎn)生了一個(gè)分離表單和內(nèi)容的想法。而且,在許多公司里規(guī)劃設(shè)計(jì)者的角色和程序設(shè)計(jì)者是分開的。于是,這樣的一個(gè)模板解決方案產(chǎn)生了........

In our company for example, the development of an application goes on as follows: After the requirements docs are done, the interface designer makes mockups of the interface and gives them to the programmer. The programmer implements business logic in PHP and uses interface mockups to create skeleton templates. The project is then handed off to the HTML designer/web page layout person who brings the templates up to their full glory. The project may go back and forth between programming/HTML a couple of times. Thus, it's important to have good template support because programmers don't want anything to do with HTML and don't want HTML designers mucking around with PHP code. Designers need support for config files, dynamic blocks and other interface issues, but they don't want to have to deal with intricacies of the PHP programming language.

例如在我們公司,一個(gè)應(yīng)用程序的開發(fā)流程如下:在提交計(jì)劃文檔之后,界面設(shè)計(jì)者[美工]制作了網(wǎng)站的外觀模型,然后把它交給后臺(tái)程序員。程序員使用PHP實(shí)現(xiàn)商業(yè)邏輯,同時(shí)使用外觀模型做成基本架構(gòu)。然后工程被返回到html頁面設(shè)計(jì)者繼續(xù)完善。就這樣工程可能在后臺(tái)程序員和頁面設(shè)計(jì)者之間來來回回好幾次。由于后臺(tái)程序員不喜歡干預(yù)任何有關(guān)html標(biāo)簽,同時(shí)也不需要美工們和php鬼混在一起;美工設(shè)計(jì)者只需要配置文件,動(dòng)態(tài)區(qū)塊和其他的界面部分,不必要去接觸那些錯(cuò)綜復(fù)雜的php代碼 。因此,這時(shí)候有一個(gè)很好的模板支持就顯得很重要了。
Looking at many templating solutions available for PHP today, most of them provide a rudimentary way of substituting variables into templates and do a limited form of dynamic block functionality. But our needs required a bit more than that. We didn't want programmers to be dealing with HTML layout at ALL, but this was almost inevitable. For instance, if a designer wanted background colors to alternate on dynamic blocks, this had to be worked out with the programmer in advance. We also needed designers to be able to use their own configuration files, and pull variables from them into the templates. The list goes on.

縱觀現(xiàn)今存在的許多php模板解決方案,大多數(shù)都只是提供了用模板取代變量和將動(dòng)態(tài)區(qū)塊的功能有限的格式化的基本方法。但是我們的需求比這個(gè)要高的多。我們完全不想要php程序員去設(shè)計(jì)html頁面,可是這又是不可避免的。例如:如果美工想要在動(dòng)態(tài)區(qū)塊之間交替不同的背景顏色,他就可能得和程序員預(yù)先說好。同樣,美工們也應(yīng)該有自己對(duì)于頁面設(shè)計(jì)的配置文件,這同樣可以通過變量把他們拉到模板里邊去。繼續(xù)。

We started out writing out a spec for a template engine back in late 1999. After finishing the spec, we began to work on a template engine written in C that would hopefully be accepted for inclusion with PHP. Not only did we run into many complicated technical barriers, but there was also much heated debate about exactly what a template engine should and should not do. From this experience, we decided that the template engine should be written in PHP as a class, for anyone to use as they see fit. So we wrote an engine that did just that and SmartTemplate came into existence (note: this class was never submitted to the public). It was a class that did almost everything we wanted: regular variable substitution, supported including other templates, integration with config files, embedding PHP code, limited 'if' statement functionality and much more robust dynamic blocks which could be multiply nested. It did all this with regular expressions and the code turned out to be rather, shall we say, impenetrable. It was also noticably slow in large applications from all the parsing and regular expression work it had to do on each invocation. The biggest problem from a programmer's point of view was all the necessary work in the PHP script to setup and process templates and dynamic blocks. How do we make this easier?

早在1999年后期,我們就已經(jīng)開始為模板引擎寫說明文檔。在完成這個(gè)文檔之后,我們開始用c寫一個(gè)模板引擎,并有希望被包含到php里去。在 撞上了許多的技術(shù)難題的同時(shí),“什么是模板應(yīng)該做的,什么不該做”這個(gè)問題,也被熱烈的討論著。從這些經(jīng)驗(yàn),我們決定應(yīng)該用Php將模板引擎寫成一個(gè)類,讓任何覺得合適的人使用它。所以我們寫了一個(gè)引擎,從此就有了smarty.(注:這個(gè)類以前從來沒有公開發(fā)表過)。這個(gè)類幾乎達(dá)到了我們所有的要求:常規(guī)變量替換,支持包括其他模板,使用配置文件集成設(shè)置,嵌入Php代碼,限制'if'語句的作用,還有更多的可以多層嵌套的健壯的動(dòng)態(tài)區(qū)塊。它用常規(guī)表達(dá)式做到這一切,于是代碼變得相當(dāng),我們可以說:令人費(fèi)解的。在每次調(diào)用的時(shí)候,都要去解析 那些語法和常規(guī)表達(dá)式,于是在大型應(yīng)用的時(shí)候,它顯然慢了下來。在程序員的眼光看來,最大的問題還是使用php腳本建立和處理模板和動(dòng)態(tài)區(qū)塊的所有必要工作。我們應(yīng)該如何使他變得更簡單?

Then came the vision of what ultimately became Smarty. We know how fast PHP code is without the overhead of template parsing. We also know how meticulous and overbearing the PHP language may look to the average designer, and this could be masked with a much simpler templating syntax. So what if we combined the two strengths? Thus, Smarty was born...

我們可以想象smarty應(yīng)該有怎樣的最后表現(xiàn)。我們知道php代碼如果沒有了模板解析的開銷將有多快,我們也知道從一般的美工看來php語言是多么的"恐怖",然而這一切可以被一種更簡單的模板語法掩飾掉。我們應(yīng)該怎樣把這兩種方法的長處結(jié)合起來?
于是,Smarty誕生了......

Article précédent: Article suivant: