Questions tagged [templating]

Templating systems are generally composed of a Template Engine, a Content Resource and a Template Resource.

A templating system is composed of:

  • A template engine: the primary processing element of the system;
  • Content resource: any of various kinds of input data streams, such as from a relational database, XML files, JSON, LDAP directory, and other kinds of local or networked data;
  • Template resource: web templates specified according to a template language; The template and content resources are processed and combined by the template engine to mass-produce web documents. For purposes of this article, web documents include any of various output formats for transmission over the web via HTTP, or another internet protocol.
958 questions
542
votes
11 answers

How to concatenate strings in twig

Anyone knows how to concatenate strings in twig? I want to do something like: {{ concat('http://', app.request.host) }}
stoefln
  • 14,498
  • 18
  • 79
  • 138
224
votes
19 answers

How to replace ${} placeholders in a text file?

I want to pipe the output of a "template" file into MySQL, the file having variables like ${dbName} interspersed. What is the command line utility to replace these instances and dump the output to standard output? The input file is considered to be…
Dana the Sane
  • 14,762
  • 8
  • 58
  • 80
184
votes
24 answers

Bash Templating: How to build configuration files from templates with Bash?

I'm writing a script to automate creating configuration files for Apache and PHP for my own webserver. I don't want to use any GUIs like CPanel or ISPConfig. I have some templates of Apache and PHP configuration files. Bash script needs to read…
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
152
votes
8 answers

Passing variables through handlebars partial

I'm currently dealing with handlebars.js in an express.js application. To keep things modular, I split all my templates in partials. My problem: I couldn't find a way to pass variables through an partial invocation. Let's say I have a partial which…
Pascal Precht
  • 8,803
  • 7
  • 41
  • 53
103
votes
6 answers

Is it possible to use Razor View Engine outside asp.net

If I look at the Razor View Engine, then I see a very nice and concise syntax that is not particularly tied to generating html. So I wonder, how easy would it be to use the engine outside asp.net in a "normal" .net environment for example to…
Thomas
  • 7,933
  • 4
  • 37
  • 45
92
votes
5 answers

How to include a sub-view in Blade templates?

I am trying to set up a site using laravel, but I'm really having trouble with basic things that the documentation just doesn't cover. In this case, I see that it says I can include one view inside another by using @include('view.name'). What is…
Benubird
  • 18,551
  • 27
  • 90
  • 141
88
votes
6 answers

conditional on last item in array using handlebars.js template

I am leveraging handlebars.js for my templating engine and am looking to make a conditional segment display only if it is the last item in array contained in the templates configuration object. { columns:…
techie.brandon
  • 1,638
  • 2
  • 18
  • 27
82
votes
8 answers

Is there any way to return HTML in a PHP function? (without building the return value as a string)

I have a PHP function that I'm using to output a standard block of HTML. It currently looks like this:

I want to return…
seanyboy
  • 5,623
  • 7
  • 43
  • 56
76
votes
12 answers

What's a good way of doing string templating in .NET?

I need to send email notifications to users and I need to allow the admin to provide a template for the message body (and possibly headers, too). I'd like something like string.Format that allows me to give named replacement strings, so the template…
Simon
  • 25,468
  • 44
  • 152
  • 266
64
votes
4 answers

How to reference CSS / JS / image resource in Facelets template?

I've done tutorial about Facelets templating. Now I've tried to create a page that isn't in same directory as the template. I've got problems with page style, because of styles are referenced with relative path like so:
kravemir
  • 10,636
  • 17
  • 64
  • 111
62
votes
6 answers

How to echo a default value if value not set blade

I would like to know what would be the best way to display a default value if the given value is not set. I have the following in a blade file (I can not guaranty that the key is set, it depends on a multitude of factors). {{ $foo['bar'] }} I would…
paquettg
  • 1,364
  • 1
  • 9
  • 16
61
votes
4 answers

Best way to handle data attributes in Slim

I was evaluating Slim as a replacement for HAML in a personal project, and it doesn't appear to handle HTML5 data attributes as gracefully as HAML. I was hoping someone may have also run into this, or may have known about an option/syntax I haven't…
mmoss
  • 713
  • 1
  • 5
  • 5
54
votes
2 answers

comment foreach binding vs foreach binding in knockoutjs

In my HTML I can define these knockout foreach bindings:
vs
Where are the differences between…
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
47
votes
4 answers

What is a templating language?

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?
Nandini Bhaduri
  • 1,835
  • 4
  • 18
  • 31
1
2 3
63 64