templating

Partial HAML templating in Ruby without Rails

倾然丶 夕夏残阳落幕 提交于 2019-12-18 10:49:27
问题 I really don’t need the overhead of Rails for my very small project, so I’m trying to achieve this just using just plain Ruby and HAML. I want to include another HAML file inside my HAML template. But I haven’t found a good—or really usable—way of doing this. For example, I have these two HAML files: documents.haml %html %body = include(menu.haml) body %article … menu.haml %ul %li %a whatever … Include is obviously not the way to go here. But it does a nice job describing what I’m trying to

Which templating engine can I use with both JS and PHP? [closed]

筅森魡賤 提交于 2019-12-18 10:22:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm looking for a simple Template engine that works both on client side with JS ánd on server side with PHP. That means I want to be able to use the same template definition for both use cases. Do you know any templating engines that have official implementations in both JS and PHP? 回答1: If you like JS->PHP

How to change head elements of a page when using ui:composition

隐身守侯 提交于 2019-12-17 18:52:15
问题 I want to ask a question that i have a master template like this <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Login</title> </h:head> <h:body> <div id="top"> <ui:insert name="top"> <ui:include src="header.xhtml" id="header"/> </ui:insert>

What is a templating language?

无人久伴 提交于 2019-12-17 18:28:32
问题 I was reading somewhere that PHP is a templating language. What is exactly a templating language? What makes PHP one? What are the other templating languages? 回答1: The premise behind a template language is that the language is "embedded" within some other master document. Specifically, on your average document, the total size of the document is mostly document source than template language. Consider two contrived examples: print "This is a simple document. It has three lines." print "On the

Iterate through keys/values in Hogan.js

﹥>﹥吖頭↗ 提交于 2019-12-14 04:17:00
问题 Is there a way to iterate through keys and values in an object using Hogan.js? I'm unable to find such documented functionality - only iteration over arrays seems to be documented. Is it even possible to iterate through objects in hogan.js (or any other moustache.js implementation)? 回答1: There is no way to directly iterate over the keys and values in an object in Hogan.js, what sub_stantial is doing is essentialy iterating over an array. Depending on what you want to do you need a bit of

How can I convert erb to html?

强颜欢笑 提交于 2019-12-13 14:48:01
问题 Imagine in rails I have @template that is an instance of ActionTemplate::View . Question is: How can I convert @template whose @template.source is <%= "hello from erb" %> to hello from erb ?? thanks 回答1: Try this... ERB.new(@template.source).result ERB#new 回答2: Well... messing around with ActionView::Template.new outside of Rails is not really recommended. You need a ton of stuff setup beforehand (init and render) If you do want to just use ERB, then go with this example require 'erb' x = 42

using a loop in a template

蓝咒 提交于 2019-12-13 06:32:36
问题 I started writing my own small scaled framework and i have gotten to the templating part of it. So far i have been able to do simple variable replacing with the following code: public function view($page, $vars) { if(!file_exists('system/views/' . $page . '.php')) { trigger_error("No Template found", E_USER_ERROR); } $tempArray = file_get_contents('system/views/' . $page . '.php'); foreach($vars as $key => $value) { $tempArray = str_replace('{' . $key . '}', $value, $tempArray); } print

Call 1 view in Codeigniter but share header/footer among all views? [duplicate]

送分小仙女□ 提交于 2019-12-13 03:06:35
问题 This question already has answers here : Load header and footer view in CI (4 answers) Closed 6 years ago . Loving Codeigniter, but I'm finding it annoying that I have to call a header, footer and the main view for each controller. What is the best way to share a header/footer among all views and minimize replication of code. I don't want to use a template engine. 回答1: create a view, let's call it template.php with this code <?php $this->load->view('header'); $this->load->view($view); $this-

How to create angularjs dynamic template with custom directives?

做~自己de王妃 提交于 2019-12-13 01:29:21
问题 I want to create some kind of template with angularjs that uses custom directives and then according to the attributes of these directives it creates input fields, for example if you have this directive in the template : <cms:input type='text' size='14' default='this is a text' label='Content Header' ></cms:input> <cms:input type='textarea' size='50' default='this is a text area' label='Content Paragraph' ></cms:input> and this is the code of the directive app.directive('cmsInput', function()

VueJS with HAML/Jade/Pug-like templating

孤者浪人 提交于 2019-12-12 12:13:50
问题 I'm using both Vue.js and HAML in my current project. The templates are parsed by HAML, converted into HTML, then parsed by Vue. For instance: #pagecontent.nonscrolling %h2 Demand forecasts %label{ for:"location-type" } Select location type %select.form-control#location-type{ v-model:"locationType" } %option{ v-bind:value:"'foo'" } Foo It works ok, but it's a bit disconcerting worrying whether all the Vue syntax will make it unscathed through the HAML parser. But I really like this type of