Download the PHP package windwork/template without Composer

On this page you can find all versions of the php package windwork/template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package template

Windwork模板引擎

Windwork模板引擎模板引擎是一个超轻量级“编译”型模板引擎,10分钟即可完全掌握。

Windwork通过模板引擎将视图从业务逻辑分离,便于前端与程序的分工协作。前端或设计师只需要简单的模板标签语法即可进行模板开发。 视图层将模型化的数据渲染为某种表现形式。负责用它得到的信息生成应用程序需要的任何表现界面。

模板示例

安装

该组件已包含在Windwork框架中,如果你已安装Windwork框架则可以直接使用。

1、模板文件夹

Windwork模板引擎

2、使用模板

在Windwork控制器中使用 $this->view()调用模板实例。

2.1 模板变量赋值:

2.2 显示模板:

默认模板文件存放于模块文件夹下的view文件夹中,使用render方法显示模板。

2.3 在控制器中使用模板

如下为在Windwork MVC的控制器中使用模板引擎

3、模板引擎语法

3.1 输出

输出代码写在两对大括号中间,如{{$var}} 被解析成 。 {{后不能有空格,否则不会被解析。 非输出标签只有一对大括号。

3.1.1 变量输出

3.1.2 常量输出

{{CONST_XX}} // 模板中的常量约定全部为大写

3.1.3 调用类、对象、函数并输出返回值

3.1.4 url 链接标签

1)使用url标签 {{url $mod.$ctl.$act/param1/param2/paramk1:paramv1/...}} 2)使用url函数 {{url("$mod.$ctl.$act/param1/param2/paramk1:paramv1/...")}}

3.1.5 lang

3.1.5.1 lang 语言标签:

{{lang nickname}}

3.1.5.2 lang函数:

{{lang("nickname")}}

3.1.5.3 {{lang xx}}与 {{lang('xx')}}的区别:

3.2 模板逻辑运算标签

3.2.1 foreach

3.2.2 if

3.2.3 for

4、扩展语法

4.1 执行代码段

4.2 static 不解析内容标签

模板中有些部分我们不希望进行解析“编译”,这时我们需要使用static标签。

4.3 模板继承

模板继承可以在父模板中定义继承后的模板中可重新定义的区域。

4.3.1 使用模板继承

第一步,使用ext标签定义继承的模板文件,如下

第二步,使用block标签在父模板文件定义可修改的区块,然后在继承的模板中使用同样的区块名修改区块内容。

案例:使用区块定义重写父模板中的区块

父模板

子模板extend.html 继承 base_tpl.html

extend.html模板解析后内容为

4.3.2 保留父模板区块内容的语法

在继承模板的区块中嵌入{parent}标签,该标签将被替换成父区块中的代码。

将解析为

4.4 模板注释

1) 模板标签注释

可在模板标签两边加上HTML注释,模板解析时自动清掉HTML注释

服务端注释

使用 { 注释内容 } 的格式添加模板注释,模板编译后自动去掉注释内容。

5、单独使用Windwork模板引擎

Windwork控制器中已经初始化好模板引擎,你只需要在配置文件中设置模板参数即可。而当你只使用windwork模板引擎,不使用完整的windwork MVC时,创建模板对象案例如下:

6、配置参数

通过模板引擎构造函数设置模板配置参数,可配置参数如下:

参数 示例 说明
tplDir app/view 模板目录。
compileCheck true 渲染模板时,是否检查模板文件是否需要编译
compileId zh_CN 设置模板识别id,用于区分不同国家的语言,不同用户使用不同模板等
compileDir data/template “编译”后的模板文件保存的文件夹
compileForce false 是否强制每次都“编译”,建议开发环境为true,正式环境为false
compileMerge true 编译后的模板文件是否合并成一个文件,建议开发环境为false,正式环境为true
defaultTpl {$mod}/{$ctl}/{$act}.html 默认模板文件,$view->render()不传参时使用的模板
defaultSpareTpl '' 默认备用模板文件,为空或跟默认模板文件一样,则不使用备用模板文件

注:为灵活支持模板文件的查找,模板目录选项可使用{0}、{1}、{2}等匹配规则,运行时$view->render($file)的$file参数中的第n个文件夹将替换掉大括号中对应的n数字的配置。 例如:

7、自定义模板引擎

如果你有兴趣,也可以自定义模板引擎,在Windwork中使用。 请implements \wf\template\EngineInterface 接口实现自定义模板。




要了解更多?


All versions of template with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package windwork/template contains the following files

Loading the files please wait ....