1

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).

vaclav_o
  • 1,705
  • 3
  • 15
  • 24

3 Answers3

2

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.
BuriB
  • 1,343
  • 9
  • 16
  • He wants to generate PHP templates from SOY files. The php-closure library let's you compile SOY to JS from within PHP. You still end up with compiled JS. The closest solution I can think of would be to write some kind of soy to template. – Matt Feb 27 '15 at 01:42
0

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.
Map X
  • 444
  • 1
  • 4
  • 14
0

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

oujesky
  • 2,837
  • 1
  • 19
  • 18