Handlebarsjs PHP rendering

前端 未结 4 1533
北海茫月
北海茫月 2020-12-28 15:50

I was wondering if there was something out there that would allow php to render Handlebarsjs templates on the server side.

thanks

相关标签:
4条回答
  • 2020-12-28 16:09

    This heavily depends on how you are dealing with Handlebars templates. Are you embedding them in the HTML? Are you loading them separately? Are you saving them locally and then compiling? If you are embedding in HTML, you can just put some PHP tags there and you're done.

    If you are loading them separately, you'll have to load the template file within PHP (e.g: file_get_contents, fopen/fread), process the information you want, and then save the file again (e.g.: file_put_contents, fopen/fwrite).

    PHP can render anything. Just put your PHP open/close tags and do your magic.

    0 讨论(0)
  • 2020-12-28 16:15

    I start a new project to do this task, its here :

    https://github.com/XaminProject/handlebars.php

    Not so much tested but its usable enough.

    0 讨论(0)
  • 2020-12-28 16:29

    lightncandy is a pure PHP library that supports almost all features of handlebars (Does not require a PECL library)

    0 讨论(0)
  • 2020-12-28 16:30

    Try mustache.php it's not the same but handlebarsjs is based on it so it's very much alike.

    0 讨论(0)
提交回复
热议问题