templating

How to include a sub-view in Blade templates?

天涯浪子 提交于 2019-11-26 22:15:13
问题 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 view.name? Where is it saved? I tried creating a file app/views/view.name.blade.php , but it wasn't read. How does the file name map to the blade name? 回答1: EDIT: Below was the preferred solution in 2014. Nowadays you should use @include , as

How to concatenate strings in twig

家住魔仙堡 提交于 2019-11-26 15:39:13
Anyone knows how to concatenate strings in twig? I want to do something like: {{ concat('http://', app.request.host) }} Alessandro Desantis This should work fine: {{ 'http://' ~ app.request.host }} To add a filter - like 'trans' - in the same tag use {{ ('http://' ~ app.request.host) | trans }} As Adam Elsodaney points out , you can also use string interpolation , this does require double quoted strings: {{ "http://#{app.request.host}" }} Also a little known feature in Twig is string interpolation : {{ "http://#{app.request.host}" }} The operator you are looking for is Tilde (~), like

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

社会主义新天地 提交于 2019-11-26 14:56:29
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? user Sed ! Given template.txt: The number is ${i} The word is ${word} we just have to say: sed -e "s/\${i}/1/" -e "s/\${word}/dog/" template.txt Thanks to Jonathan Leffler for the tip to pass multiple -e arguments to the same sed invocation. plockc Update Here is a solution from yottatsa on a similar question that only does replacement for variables like $VAR or ${VAR}, and is a

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

耗尽温柔 提交于 2019-11-26 14:06:06
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 templates, make variable substitution and output parsed templates into some folder. What is the best way to do that? I can think of several ways. Which one is the best or may be there are some better ways to do that? I want to do that in pure Bash (it's easy in PHP for example) 1) How to replace ${} placeholders in a text file? template.txt: the number

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

我的梦境 提交于 2019-11-26 11:11:42
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 generate text, code,... Any pointer, example, comment or explanation is welcome. marcind There are two issues here: Yes, you can run the Razor View Engine outside of the context of an ASP.NET app domain, as explained in Andrew's blog: http://vibrantcode.com/blog/2010/11/16/hosting-razor-outside-of-aspnet-revised-for-mvc3-rc.html However, Razor is still

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

空扰寡人 提交于 2019-11-26 10:57:19
问题 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 can look like this: Dear {User}, Your job finished at {FinishTime} and your file is available for download at {FileURL}. Regards, -- {Signature} What\'s the simplest way for me to do that? 回答1: Use a templating engine. StringTemplate is one of

Passing variables through handlebars partial

岁酱吖の 提交于 2019-11-26 06:58:53
问题 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 looks like this: <div id=myPartial> <h1>Headline<h1> <p>Lorem ipsum</p> </div> Let\'s assume I registered this partial with the name \'myPartial\'. In another template I can then say something like: <section> {{> myPartial}} </section> This

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

我的未来我决定 提交于 2019-11-26 05:55:23
问题 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 templates, make variable substitution and output parsed templates into some folder. What is the best way to do that? I can think of several ways. Which one is the best or may be there are some better ways to do that? I want to do that in pure Bash

When using <ui:composition> templating, where should I declare the <f:metadata>?

ⅰ亾dé卋堺 提交于 2019-11-26 04:50:50
I have made a lot of progress in converting my JSF applications to book-markable pages, but I am wondering if I am doing it the right way. One question is that is there a best-practice location for the f:metadata tags? My typical Facelets client page looks like this: <ui:composition template="./pattern.xhtml"> <ui:define name="content"> <f:metadata> <f:viewParam name="userId" value="#{bean.userId}" /> <f:viewParam name="startRecord" value="#{bean.startRecord}" /> <f:viewParam name="pageSize" value="#{bean.pageSize}" /> <f:viewParam name="sort" value="#{bean.sort}" /> </f:metadata> <h1>Data

How to concatenate strings in twig

[亡魂溺海] 提交于 2019-11-26 04:32:44
问题 Anyone knows how to concatenate strings in twig? I want to do something like: {{ concat(\'http://\', app.request.host) }} 回答1: This should work fine: {{ 'http://' ~ app.request.host }} To add a filter - like 'trans' - in the same tag use {{ ('http://' ~ app.request.host) | trans }} As Adam Elsodaney points out, you can also use string interpolation, this does require double quoted strings: {{ "http://#{app.request.host}" }} 回答2: Also a little known feature in Twig is string interpolation: {{