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

annuaire recherche
Smarty模板編譯引擎 I.開始 第一章. 什么是Smarty? 第二章. 安裝 要求 基本安裝 擴(kuò)展設(shè)置 II.模板設(shè)計(jì)者篇 第三章.基本語(yǔ)法 注釋 函數(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

Chapter 1. What is Smarty?

第一章.什么是Smaty?

Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. This is best described in a situation where the application programmer and the template designer play different roles, or in most cases are not the same person. For example, let's say you are creating a web page that is displaying a newspaper article. The article headline, tagline, author and body are content elements, they contain no information about how they will be presented. They are passed into Smarty by the application, then the template designer edits the templates and uses a combination of HTML tags and template tags to format the presentation of these elements (HTML tables, background colors, font sizes, style sheets, etc.) One day the programmer needs to change the way the article content is retrieved (a change in application logic.) This change does not affect the template designer, the content will still arrive in the template exactly the same. Likewise, if the template designer wants to completely redesign the templates, this requires no changes to the application logic. Therefore, the programmer can make changes to the application logic without the need to restructure templates, and the template designer can make changes to templates without breaking application logic.

Smarty是一個(gè)php模板引擎。更準(zhǔn)確的說,它分開了邏輯程序和外在的內(nèi)容,提供了一種易于管理的方法??梢悦枋鰹閼?yīng)用程序員和美工扮演了不同的角色,因?yàn)樵诖蠖鄶?shù)情況下 ,他們不可能是同一個(gè)人。例如,你正在創(chuàng)建一個(gè)用于瀏覽新聞的網(wǎng)頁(yè),新聞標(biāo)題,標(biāo)簽欄,作者和內(nèi)容等都是內(nèi)容要素,他們并不包含應(yīng)該怎樣去呈現(xiàn)。在Smarty的程序里,這些被忽略了。模板設(shè)計(jì)者們編輯模板,組合使用html標(biāo)簽和模板標(biāo)簽去格式化這些要素的輸出(html表格,背景色,字體大小,樣式表,等等)。有一天程序員想要改變文章檢索的方式(也就是程序邏輯的改變)。這個(gè)改變不影響模板設(shè)計(jì)者,內(nèi)容仍將準(zhǔn)確的輸出到模板。同樣的,哪天美工吃多了想要完全重做界面,也不會(huì)影響到程序邏輯。因此,程序員可以改變邏輯而不需要重新構(gòu)建模板,模板設(shè)計(jì)者可以改變模板而不影響到邏輯。

Now for a short word on what Smarty does NOT do. Smarty does not attempt to completely separate logic from the templates. There is no problem with logic in your templates under the condition that this logic is strictly for presentation. A word of advice: keep application logic out of the templates, and presentation logic out of the application. This will most definately keep things manageable and scalable for the foreseeable future.

現(xiàn)在簡(jiǎn)短的說一下什么是smarty不做的。smarty不嘗試將邏輯完全和模板分開。如果邏輯程序嚴(yán)格的用于頁(yè)面表現(xiàn),那么它在模板里不會(huì)出現(xiàn)問題。有個(gè)建議:讓應(yīng)用程序邏輯遠(yuǎn)離模板, 頁(yè)面表現(xiàn)邏輯遠(yuǎn)離應(yīng)用程序邏輯。這將在以后使內(nèi)容更容易管理,程序更容易升級(jí)。

One of the unique aspects about Smarty is the template compling. This means Smarty reads the template files and creates PHP scripts from them. Once they are created, they are executed from then on. Therefore there is no costly template file parsing for each request, and each template can take full advantage of PHP compiler cache solutions such as Zend Accelerator (http://www.zend.com) or PHP Accelerator (http://www.php-accelerator.co.uk).

Smarty的特點(diǎn)之一是"模板編譯"。意思是Smarty讀取模板文件然后用他們創(chuàng)建php腳本。這些腳本創(chuàng)建以后將被執(zhí)行。因此并沒有花費(fèi)模板文件的語(yǔ)法解析,同時(shí)每個(gè)模板可以享受到諸如Zend加速器(http://www.zend.com) 或者PHP加速器(http://www.php-accelerator.co.uk)。這樣的php編譯器高速緩存解決方案。

Some of Smarty's features:

Smaty的一些特點(diǎn):

  • It is extremely fast.
    非常非常的快!

  • It is efficient since the PHP parser does the dirty work.
    用php分析器干這個(gè)苦差事是有效的

  • No template parsing overhead, only compiles once.
    不需要多余的模板語(yǔ)法解析,僅僅是編譯一次

  • It is smart about recompiling only the template files that have changed.
    僅對(duì)修改過的模板文件進(jìn)行重新編譯

  • You can make custom functions and custom variable modifiers, so the template language is extremely extensible.
    可以編輯'自定義函數(shù)'和自定義'變量',因此這種模板語(yǔ)言完全可以擴(kuò)展

  • Configurable template delimiter tag syntax, so you can use {}, {{}}, <!--{}-->, etc.
    可以自行設(shè)置模板定界符,所以你可以使用{}, {{}}, <!--{}-->, 等等

  • The if/elseif/else/endif constructs are passed to the PHP parser, so the {if ...} expression syntax can be as simple or as complex as you like.
    諸如 if/elseif/else/endif 語(yǔ)句可以被傳遞到php語(yǔ)法解析器,所以 {if ...} 表達(dá)式是簡(jiǎn)單的或者是復(fù)合的,隨你喜歡啦

  • Unlimited nesting of sections, ifs, etc. allowed.
    如果允許的話,section之間可以無(wú)限嵌套

  • It is possible to embed PHP code right in your template files, although this may not be needed (nor recommended) since the engine is so customizable.
    引擎是可以定制的.可以內(nèi)嵌php代碼到你的模板文件中,雖然這可能并不需要(不推薦)

  • Built-in caching support
    內(nèi)建緩存支持

  • Arbitrary template sources
    獨(dú)立模板文件

  • Custom cache handling functions
    可自定義緩存處理函數(shù)

  • Plugin architecture
    插件體系結(jié)構(gòu)

Article précédent: Article suivant: