rifer/test-update-cml 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rifer/test-update-cml

Composer 安装命令:

composer require rifer/test-update-cml

包简介

CakePHP plugin providing further abstraction of the View layer by replacing the procedural PHP code with an XML based markup

README 文档

README

The Cake Markup Language is a CakePHP plugin which provides abstraction of the View layer by replacing procedural PHP code with an XML based markup.

Using CakeML helps keep your View code clean and organized, while also maintaining a strict MVC convention by limiting application logic in the View layer.

The main features of the plugin include:

  • Familiar Syntax: The syntax used for the CakeML markup is identical to that used for XHTML, so there's no new formatting or patterns to learn, and any IDE or code editor capable of highlighting XML will also do so for your View files.
  • Ready for Designers: Due to the common syntax your View files become even more accessible to designers and non-developers, allowing them to introduce code themselves without any previous technical knowledge.
  • Simple Templating: The plugin provides basic template logic out-of-the-box, such as if/elseif/else conditional statements, foreach loops and switches, as well as the View blocks already available in CakePHP for creating dynamic content.
  • Internal Debugging: By enabling debug mode on the Parser component you can quickly review the compiled View before it's processed, giving you a clear idea of the generated code before it's rendered as the output.
  • Extensible by Design: As the markup tags used in CakeML are grouped together under a common namespace, you can easily import your own custom or third-party namespaces from a CakePHP plugin, allowing you to reuse tags in other applications.
  • Plug and Play: Using the plugin is as simple as including the Parser component, which doesn't limit you from still using the normal ".ctp" files, as you can even use both formats for different Views in the same Controller.
  • Compatibility: All of the View features currently in CakePHP are still available, such as themes, layouts, elements, content blocks and helpers, with both layouts and elements also able to contain CakeML markup.

To start using the Cake Markup Language it's as easy as including the ParserComponent from the plugin in your Controller, for example:

public $components = array(
	'Cml.Parser' => array(
		'ignoreAction' => array('example') // allow "example" action to continue using "example.ctp"
	)
);

View, layout and element files using CakeML are saved with the ".cml" extension, differenciating them from standard ".ctp" templates. To create a View, simply include the CakeML markup along with your static HMTL, CSS and JavaScript client code.

<div id="example">
	<cake:out value="Hello World" />
</div>

You can also use conditional statements with the php namespace, as well as View variables, to create dynamic content. For example, by setting $this->set("text", "Hello World"); from your Controller, you can then read it in the View using %{variable}, also displaying it conditionally with the following:

<php:if expr="!empty(%{text})">
	<cake:out value="%{text}" />
<php:else />
	<cake:out value="Nothing here" />
</php:if>

However, the same can also be acheived by just using the default attribute:

<cake:out value="%{text}" default="Nothing here" />

More complex operations include for, foreach and while loops, which provide the ability of rapid templating, including automatic variable declaration and default values for empty arrays.

<php:foreach var="products" default="No products found">
	<cake:out value="%{COUNT}. %{KEY} = &quot;%{VALUE}&quot;" safe="true" />
</php:foreach>

The cake namespace also provides many tags for common usage, such as including elements, for example:

<cake:element name="sidebar" options="['example' => %{value}]" />

You can also easily create links, which in the following examples use #{literal} to load a translated string, as well as including additional HTML content.

<cake:link value="#{Read more}" url="['controller' => 'Posts', 'action' => 'view', %{postId}]" />

<cake:link url="['controller' => 'Posts', 'action' => 'view', %{postId}]">
	<span>#{Read more}</span>
</cake:link>

Probably the most important feature is forms, which can also be generated quickly.

<cake:form model="Example" submit="#{Send}" options="['action' => 'add']">
	<cake:input field="Example.column" options="['type' => 'number']" />
</cake:form>

The cake namespace also allows you to access any core or third-party helper, which means no change is needed to use your existing helpers.

<cake:helper name="Example" get="someProperty" />

<cake:helper name="Example" call="someFunction" args="['Hello World']" set="something" />
<cake:out value="%{something}" safe="0" />

To get working quickly check out the Quick Start or Hello World tutorials from the documentation.

Requirements

  • CakePHP 2+
  • PHP 5.3+

Documentation

Full documentation is included with the plugin, and can be found in the Docs directory of this repository.

Support

For support, bugs and feature requests, please use the issues section of this repository.

Contributing

If you'd like to contribute new features, enhancements or bug fixes to the code base just follow these steps:

There may be some discussion regarding your contribution to the repository before any code is merged in, so be prepared to provide feedback on your contribution if required.

A list of contributors to the Cake Markup Language can be found here.

Licence

Copyright 2013 James Watts (CakeDC). All rights reserved.

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.

Acknowledgements

A special thanks to Larry Masters, the founder of CakePHP, as well as the entire CakeDC team for their feedback and support.

rifer/test-update-cml 适用场景与选型建议

rifer/test-update-cml 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cakephp」 「language」 「markup」 「cake」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rifer/test-update-cml 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rifer/test-update-cml 我们能提供哪些服务?
定制开发 / 二次开发

基于 rifer/test-update-cml 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-16