简体   繁体   中英

Using google closure soy templates in php

Is there any possibility to use Google closure soy templates with PHP like JAVA? Some class generator which generates PHP classes instead of JAVA classes or feature to using soy templates in php code? I like idea of using same templates in both sides (Javascript for client and JAVA for server).

I haven't tried this out but looks good and exactly what you need.

https://github.com/kennberg/php-closure

Features:

  • Compile locally using Google Closure Compiler
  • Support for Google Closure Templates and Soy-To-Js Compiler
  • Handles caching and recompilation of sources.
  • Add directories with source files.

It could be done with two steps:

  1. Writing a C/C++ adapter which calls official JAVA methods through JNI, such as cpp-closure-template . The adapter requires a modified jar ball as Hello World Using Java - closure tools - Google Developers (adds a handler java file)
  2. A php extension utilize the adapter passing a JSON object string as data map.

I made an experimental fork of Closure Templates which supports compilation of *.soy files to PHP.

You can grab it on GitHub: https://github.com/oujesky/closure-templates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM