krzksz/phcompile 问题修复 & 功能扩展

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

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

krzksz/phcompile

最新稳定版本:v0.4.1

Composer 安装命令:

composer require krzksz/phcompile

包简介

PHP server side precompiler for AngularJS apps.

README 文档

README

Build Status

Library for server-side precompiling AngularJS templates in PHP.

The goal of using phCompile is to let you compile your HTML templates using your existing JSON REST api.

Server side compiling works in a way that lets you easily revert back all of the changes made by phCompile on the client side by either adding speciall class or attribute to the element.

phCompile is still in alpha state, bugs and api changes may occur.

Use cases

  • Serving complete website on first load for better SEO and social crawlers.
  • Reusing AngualarJS templates outside client application.
  • Static HTML page generation.
  • Faster website rendering when using big data chunks.
  • Making your website preserve minimal functionality without JavaScript enabled.

Supported AngularJS features

  • {{ }} expressions;
  • ng-repeat(without "track by");
  • ng-hide, ng-show;
  • ng-class, ng-class-even, ng-class-odd;
  • ng-bind, ng-bind-template;
  • ng-href;
  • ng-value;
  • ng-src, ng-srcset.

Roadmap

  • Remaining textual AngularJS directives,
  • Filters(currently they are expected to break expression that uses them),
  • Expressions cache,
  • Suggestions?

Quick Example

$phCompile = new \PhCompile\PhCompile(); // Create PhCompile object
$template = new \PhCompile\Template\Template($phCompile); // Create template
$template->setScope(new Scope(array('foo'=>'bar'))); // Set scope data.

$template->loadHtml('template.html'); // Load from file
$template->setHtml('<span ng-bind="foo"></span>'); // Or just from string
echo $template->compile(); // "<span ng-bind="foo">bar</span>"

Documentation

Contribute

You are welcome to contribute your own improvements and ideas. If you have any issues and feature ideas please post them at project's issues page.

Contact

If you would like you can contact me or follow via Twitter @krzksz.

Thanks

I would like to thank @danchoi for creating his AngularJS template parser in Haskell which gave me inspiration and ideas for this project.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-08