定制 evertt/slade 二次开发

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

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

evertt/slade

Composer 安装命令:

composer require evertt/slade

包简介

A templating for Laravel inspired by Ruby Slim and Laravel Blade

README 文档

README

A PHP templating engine inspired by both Ruby Slim and Laravel Blade

Disclaimer

I want to let you know that I don't believe this code is production ready yet. It's missing features to make it really powerful and although I've written tests I'm sure there are probably still important bugs I've missed. What I would really like is if you'd like to test it, look at the code and send me suggestions and pull-requests to make it better.

Install

Use

composer require evertt/slade

to include this package into your Laravel project. Then in config/app.php add Slade\ServiceProvider::class to your list of service providers.

Usage

To use this engine all you need to do is create template files that end in .slade.php instead of .blade.php.

Example

The following template

doctype html
html
  head
    title Slade
    link href="style.css"
    
    css:
      body {
        color: #333;
      }
    
  body
    h1 My first Slade template!
    
    ? $name
      p
        | Hello $name, this line only appears
        | if the name variable contains a truthy.
    
    ! $name
      p There is no name.
      
    div
      <p>
        It also works fine with just plain html.
      </p>
      
    h2 Here is a list of names of people:
    ul
      > $people
        li = $person->name
        
    + elements.footer

Could parse into the following HTML:

<!DOCTYPE html>
<html>
  <head>
    <title>Slade</title>
    <link href="style.css">
    
    <style>
      body {
        color: #333;
      }
    </style>
  </head>
  
  <body>
    <h1>My first Slade template!</h1>
    
    <p>
      Hello John Doe, this line only appears
      if the name variable contains a truthy.
    </p>
    
    <div>
      <p>
        It also works fine with just plain html.
      </p>
    </div>
    
    <h2>Here is a list of names of people:</h2>
    <ul>
      <li>Harry</li>
      <li>Ron</li>
      <li>Hermione</li>
    </ul>
    
    <footer>
      &copy; Me 2015
    </footer>
  </body>
</html>

You can also extend another template this way:

_ layouts.default
  @ content
    p This paragraph will be assigned to the 'content' section

Which will then extend for example layouts/default.slade.php and the paragraph will appear wherever the following line is included in layouts/default.slade.php:

- content

Inserting variables

As you saw, you can insert variables in a few ways. I want to show a few more.

p
  | So this is a block of text in which you can put variables.
    You can do that in the following manner:
    $var or {$var} or ${var}. The {} syntax only works if
    there's no whitespace after the { and before the } though.
    And finally you can also execute function calls like so:
    {implode(' ', $var)}. Again, make sure there's no whitespace
    immediately following the { or immediately preceding the }.

More

There's a lot more you can do. I intend to write a more complete wiki about it soon. If you'd like to contribute to the docs or the code or suggest any features then please file an issue or submit a pull-request. That would be the greatest gift for me.

evertt/slade 适用场景与选型建议

evertt/slade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 177 次下载、GitHub Stars 达 42, 最近一次更新时间为 2015 年 04 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 evertt/slade 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 42
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-18