简体   繁体   English

Yeoman / JS:在HTML模板中重复HTML块-进行编译以最终与Wordpress集成?

[英]Yeoman/JS: Repeating HTML blocks in a HTML template - compiling to eventually integrate with Wordpress?

Right, so i'm currently working on a project that will eventually be powered by a Wordpress back-end , but on the front end, will be heavily powered by CSS3 and JavaScript - perhaps even taking advantage of history API and dynamically loading in of content via AJAX. 是的,所以我目前正在一个项目中,该项目最终将由Wordpress后端提供支持,但在前端,将由CSS3JavaScript提供大量支持-甚至甚至可以利用历史记录API并动态加载通过AJAX获得内容。

I'm currently working on the static HTML templates, getting the layouts right, getting all the JS required for the interaction and navigation between pages etc. I'm currently using Yeoman as a watch server to compile my SASS templates and merge all JS modules using RequireJS . 我目前正在使用静态HTML模板,正确设置布局,获取页面之间的交互和导航所需的所有JS等。我目前使用Yeoman作为监视服务器来编译我的SASS模板并合并所有JS模块使用RequireJS

Everything's going fine, but i'm starting to notice i'm repeating a lot of HTML blocks in the HTML templates, and it's not very efficient - i want to just edit the block in one place and have it repeat however many times i need on a page - headers, footers, single blog items on blog listing pages etc. while i'm scaffolding the front-end templates. 一切都很好,但是我开始注意到我在HTML模板中重复了很多HTML块,而且效率不是很高-我只想在一个地方编辑该块,然后重复它,但是我需要多次在页面上-页眉,页脚,博客列表页面上的单个博客项目等,而我正在搭建前端模板。

Essentially, what i'd like to do is have block templates, that i can import into a parent file, loop through to generate the files i need, and once i'm ready to power the final markup by Wordpress, i can just build the project, export the static HTML files, along with the compiled JS and CSS3, and then break down the HTML into a Wordpress build at the very end. 本质上,我想做的是拥有块模板,我可以将其导入到父文件中,循环生成所需的文件,一旦准备好通过Wordpress进行最终标记 ,我就可以构建该项目,导出静态HTML文件以及已编译的JS和CSS3,然后在最后将HTML分解为Wordpress版本。

How am i best going about this? 我最好怎么办?

Integrating Jade ? 整合翡翠 Using Handlebars ? 使用车把吗? I'm not really too bothered about the shortened syntax Jade offers, i just want to be able to compile vanilla HTML from templates while i'm scaffolding. 我对Jade所提供的缩短的语法真的不太在意,我只想能够在搭建脚手架时从模板编译原始HTML。 Perhaps something like Jekyll ? 也许像杰基尔 Is there a node based version? 是否有基于节点的版本?

Is this even the right way to go about things? 这是做事情的正确方法吗? I have considered generating all my front end from JSON, and during the Wordpress integration, expose the JSON API within Wordpress, but generating all the templates in the DOM won't yield any SEO whatsoever, which is a concern. 我考虑过从JSON生成所有前端,并且在Wordpress集成期间,在Wordpress中公开JSON API,但是在DOM中生成所有模板不会产生任何 SEO,这是一个令人担忧的问题。

What do you guys think? 你们有什么感想?

I've been looking for exactly the same thing. 我一直在寻找完全相同的东西。 Being used to using jekyll for html pre-processing I assumed Yeoman would naturally support layouts and includes. 习惯使用jekyll进行html预处理时,我假设Yeoman自然会支持布局和包含布局。

Unfortunately it doesn't https://github.com/yeoman/yeoman/issues/700 不幸的是它没有https://github.com/yeoman/yeoman/issues/700

Not to say it doesn't work, but I have tried using yeoman-jekyll and after an hour of battling with it on both OSX and Windows found it not to generate as comprehensive a gruntfile as the default Yeoman init build. 并不是说它不起作用,但是我尝试使用yeoman-jekyll,并且在OSX和Windows上与之争战了一个小时之后,发现它不能像默认的Yeoman init构建那样生成全面的gruntfile。

You mentioned Jade, I'm not clued up on it but this looked like a handy post: Integrating Jade in Yeoman's server/watch/reload tasks 您提到了Jade,但我对此并不了解,但这看起来很方便: 将Jade集成到Yeoman的服务器/监视/重新加载任务中

Keep it simple, I wish I did! 保持简单,希望我做到了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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