dqd82461
2015-09-20 12:27
浏览 39
已采纳

不包含PHP的模板解决方案包括

I currently have an application that loads the html header, navigation, and footer information into an html page using separate php includes.

I am trying to re-design the application so that it no longer is dependent upon php includes (so that I can port it to PhoneGap). I have been scouring for a solution that would allow me to get the same templating functionality, while shifting the php scripts solely to the server.

I have looked at a number of the Javascript Template Frameworks - ractive, moustache, handlebars, etc. But most of those seem only data focused - which is great for that purpose, and I may use one for later. But I am looking for something to provide the bones, not the attributes. Also, each of those seems to have routing/url/seo limitations.

I have also tried some of the frameworks like Meteor, Ember, Express, and Sails but they will require a lot of additional coding to get to the same functionality I currently have - but they have the ability to define application level templating/includes. Slim Framework seems to be closest (and maybe coupling it with Twig ), but before I commit I wanted to get some feedback/option.

Is there a better way to do this?? And if so with what? And maybe even how?? Thanks all in advance for your feedback!

图片转代码服务由CSDN问答提供 功能建议

我目前有一个应用程序,使用单独的php包括将html标题,导航和页脚信息加载到html页面 。

我正在尝试重新设计应用程序,以便它不再依赖于php包含(以便我可以将其移植到PhoneGap)。 我一直在寻找一种解决方案,它可以让我获得相同的模板功能,同时将php脚本单独转移到服务器上。

我查看过一些Javascript模板框架 - ractive,小胡子,把手等等。但是大多数这些框架似乎只关注数据 - 这对于这个目的很有用,而且我可以 使用一个以后。 但我正在寻找提供骨骼的东西,而不是属性。 此外,每个似乎都有路由/ url / seo限制。

我还尝试了一些像Meteor,Ember,Express和Sails这样的框架,但是他们需要大量额外的编码才能获得我目前拥有的相同功能 - 但他们有 定义应用程序级别模板/包含的能力。 Slim Framework似乎最接近(并且可能与Twig耦合),但在我提交之前,我想得到一些反馈/选项。

有更好的方法吗? 如果是这样的话? 甚至可能怎么样? 提前感谢您的反馈!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjing4623 2015-10-07 01:25
    已采纳

    After looking through a number of the solutions, I feel that using jquery with handlebars. will actually be the best solution. It does not allow me to do exactly what I'd like to do, but it is close.

    I will keep the module pages as separate html files in a templates folder and then inject the moustache modules into the container page using jquery ajax and/or .load.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题