定制 jacmoe/template-mthaml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jacmoe/template-mthaml

最新稳定版本:1.0.8

Composer 安装命令:

composer require jacmoe/template-mthaml

包简介

A PhileCMS plugin that provides a Mthaml (Multi target HAML) template parser

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

A PhileCMS plugin that provides a Mthaml (Multi target HAML) template parser.

What is MtHaml?

MtHaml is a PHP implementation of the HAML language which can target multiple languages.

Currently supported targets are PHP and Twig, and new ones can be added easily.

This plugin uses the Twig target and allows us to write our template in HAML with Twig tags (instead of Ruby tags)

Installation

With composer

composer require jacmoe/template-mthaml

Download

  • Install Phile
  • Clone this repo into plugins/jacmoe/templateMthaml

Activation

After you have installed the plugin. You need to add the following line to your config.php file:

$config['plugins']['jacmoe\\templateMthaml'] = array('active' => true);

You need to turn off the default template Phile parser:

$config['plugins']['phile\\templateTwig'] = array('active' => false);

How to use the plugin

Once installed, this plugin now renders any haml files in your theme directory.

Template extension

You can change the default template extension (.haml) in the plugin configuration, but then you need to insert the following code at the start of each of your template files:

{% haml %}

You don't need that tag when your are using .haml files.

Example template

There is an example index.haml file in the [plugin]/example directory.

Usage examples

%ul#users
  - for user in users
    %li.user
      = user.name
      Email: #{user.email}
      %a(href=user.url) Home page

Rendered:

<ul id="users">
  {% for user in users %}
    <li class="user">
      {{ user.name }}
      Email: {{ user.email }}
      <a href="{{ user.url }}">Home page</a>
    </li>
  {% endfor %}
</ul>

Here is the example template:

!!!
%html
  %head
    %meta(charset="#{ config.charset }")
    %base(href="#{ base_url }")
    %title
      -if meta.title
        =meta.title
      =site_title
    -if meta.description
      %meta(name="description" content="#{ meta.description }")
    -if meta.robots
      %meta(name="robots" content="#{ meta.robots }")
    %meta(property="og:type" content="article")
    %meta(property="og:title" content="#{ current_page.title } | #{ site_title }")
    %meta(property="og:description" content="#{ meta.description }")
    %meta(property="og:url" content="#{ current_page.url }")
    %meta(property="og:site_name" content="#{ site_title }")
    %link(rel="stylesheet" href="#{ theme_url }/css/style.css")
    %link(rel="stylesheet" href="#{ theme_url }/css/tomorrow-night.css")
  %body
    %header#header
      .inner.clearfix
        %h1
          %a(href="#{ base_url }") = site_title
        %ul.nav
          -for page in pages
            %li
              %a(href="#{ page.url }") = page.title
    %section#content
      .inner
        =content
    %footer#footer
      .inner
        %a(href="https://github.com/PhileCMS/Phile") Phile
        was made by
        %a(href="https://github.com/PhileCMS") The PhileCMS Community
    %script(src="#{ theme_url }/js/highlight.js")
    :javascript
      hljs.initHighlightingOnLoad();

Cleaner than regular twig templates, eh?

Tricks

While the main template files have to be in MtHaml (.haml) you can include your 'old' .html partial templates, like this:

- include 'header.html'

Any Twig markup is processed by the engine, and that means that you can incrementally upgrade your theme to be using MtHaml.

If you want a full-fledged example, then check out the haml template files here: Jacmoes Cyber Soapbox Mercurial Repository

Resources

jacmoe/template-mthaml 适用场景与选型建议

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

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

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

围绕 jacmoe/template-mthaml 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-30