定制 mthaml/mthaml-bundle 二次开发

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

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

mthaml/mthaml-bundle

最新稳定版本:1.5.0

Composer 安装命令:

composer require mthaml/mthaml-bundle

包简介

This Bundle provides a HAML templating engine

关键字:

README 文档

README

HAML Symfony bundle using the MtHaml PHP HAML parser.

Build Status

Features

  • Acts as a Twig preprocessor: Supports Twig functions, filters, macros, blocks, inheritance, expressions and every Twig features
  • Mix Twig and HAML templates: You can include, extend, use and import Twig templates from HAML templates, and vice versa.
  • High performance: Templates are compiled to PHP code and cached, no parsing or runtime overhead.
  • HAML syntax supported by editors

Installation

Step 1: Download MtHaml and MtHamlBundle

Ultimately, the MtHaml files should be downloaded to the vendor/MtHaml directory, and the MtHamlBundle files to the vendor/bundles/MtHamlBundle directory.

This can be done in several ways, depending on your preference. The first method is the standard Symfony2 method.

Using Composer

$ composer require mthaml/mthaml-bundle:dev-master

(You can skip Step 2 if you are using this method as Composer will handle autoloading for you.)

Using the vendors script

Add the following lines in your deps file:

[MtHaml]
    git=git://github.com/arnaud-lb/MtHaml.git
    target=MtHaml
[MtHamlBundle]
    git=git://github.com/arnaud-lb/MtHamlBundle.git
    target=bundles/MtHamlBundle

Now, run the vendors script to download the bundle:

$ php bin/vendors install

Using submodules

If you prefer instead to use git submodules, the run the following:

$ git submodule add git://github.com/arnaud-lb/MtHamlBundle.git vendor/bundles/MtHamlBundle
$ git submodule add git://github.com/arnaud-lb/MtHaml.git vendor/MtHaml
$ git submodule update --init

Step 2: Configure the Autoloader

You can skip this step if you used composer to install the bundle.

Add the MtHaml and MtHamlBundle namespaces to your autoloader:

<?php
// app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'MtHaml'       => __DIR__ . '/../vendor/MtHaml/lib',
    'MtHamlBundle' => __DIR__ . '/../vendor/bundles',
));

Step 3: Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MtHamlBundle\MtHamlBundle(),
    );
}

Step 4: Configure the MtHamlBundle

# app/config/config.yml

framework:
    # ...
    templating:
        engines: ['haml','twig']

# required, for Symfony to load the bundle configuration
mt_haml:

(This is required, for Symfony to load the bundle configuration.)

Step 5: Use it

With the @Template() annotation:

/**
 * @Template(engine="haml")
 */
public function fooAction() {

With the @Haml() annotation:

The @Haml annotation is a sub class of @Template with engine set to haml by default.

/**
 * @Haml
 */
public function fooAction() {

With ->render()

public function bazAction() {
    $this->render('FooBundle:Bar:baz.html.haml');
}

With FOSRestBundle:

/**
 * @View(engine="haml")
 */
public function fooAction() {

Syntax

See MtHaml docs

Commands

mthaml:debug:dump

The mthaml:debug:dump command compiles a HAML templates into Twig and displays the resulting Twig template.

For debug purposes.

Example:

php ./app/console mthaml:debug:dump AcmeDemoBundle:Demo:index.html.haml

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

mthaml/mthaml-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41.82k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2011 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 41.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 39
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 38
  • Watchers: 6
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2011-11-18