templating

What is a templating language?

别等时光非礼了梦想. 提交于 2019-11-28 07:16:00
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? 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 second line is my name: " + firstName print "This is the third line." vs This is a simple document. It has

iterate over chunks of an array using ng-repeat

爷,独闯天下 提交于 2019-11-28 05:45:25
问题 My controller grabs people from the server: $scope.people = [person1, person2, person3, person4, person5,...] My template needs to display three people per line. For example if it was a table: <table> <tr> <td>person1</td><td>person2</td><td>person3</td> </tr> <tr> <td>person4</td><td>person5</td><td>person6</td> </tr> </table> I wasn't sure how to conditionally apply the <tr> when $index % 3 == 0 or what the best practices are. I know how to do this by adding grouping logic to the controller

Including one erb file into another

Deadly 提交于 2019-11-27 11:09:28
问题 I'm writing a command-line tool that will ultimately output an HTML report. The tool is written in Ruby. (I am not using Rails). I'm trying to keep the logic of the application in one set of files, and the HTML templates (the .erb files) in another set. I'm having a really annoying problem though: I can't successfully include one .erb file into another. To be specific, I'm trying to do something like this (in pseudo-code): <html> <head> <style type='text/css'> [include a stylesheet here] [and

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

心已入冬 提交于 2019-11-27 09:09:27
问题 I have a PHP function that I'm using to output a standard block of HTML. It currently looks like this: <?php function TestBlockHTML ($replStr) { ?> <html> <body><h1> <?php echo ($replStr) ?> </h1> </html> <?php } ?> I want to return (rather than echo) the HTML inside the function. Is there any way to do this without building up the HTML (above) in a string? 回答1: You can use a heredoc, which supports variable interpolation, making it look fairly neat: function TestBlockHTML ($replStr) { return

How do i specify CodeFileBaseClass from web.config?

北慕城南 提交于 2019-11-27 08:43:23
问题 i 1 am registering a user control Control in web.config : <configuration> <system.web> <pages validateRequest="false"> <controls> <add src="~/GenericControls/Toolbar.ascx" tagName="Toolbar" tagPrefix="Vista" /> </controls> </pages> </system.web> <configuration> Now, because my "user control" is a Control , rather than a UserControl (in order to support templating), this causes the Visual Studio error: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute,

conditional on last item in array using handlebars.js template

北慕城南 提交于 2019-11-27 05:15:12
问题 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: [{<obj>},{<obj>},{<obj>},{<obj>},{<obj>}] } I've already pulled in a helper to do some equality/greater/less-than comparisons and have had success identifying the initial item this way but have had no luck accessing my target array's length. Handlebars.registerHelper('compare', function

How to include a sub-view in Blade templates?

戏子无情 提交于 2019-11-27 04:35:07
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? winkbrace EDIT: Below was the preferred solution in 2014. Nowadays you should use @include , as mentioned in the other answer . In Laravel views the dot is used as folder separator. So for example I

How to add a Templating to a UserControl?

血红的双手。 提交于 2019-11-27 04:23:58
问题 This question has been asked before Web Forms :: Design Time Support For Custom Templated User Control In VS 2008 VS 2008 Using the ITemplate in a UserControl and getting a design time rendoring error how to show the controls for web user control in design time? UserControl ITemplate Property Design Time Error - Easy for a Guru... but it doesn't hurt to ask it again: How do i add templating to a UserControl in ASP.net? What hasn't worked so far Start with a new UserControl 5 , which i'll call

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

吃可爱长大的小学妹 提交于 2019-11-27 03:55:35
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? Use a templating engine. StringTemplate is one of those, and there are many. Here is the version for those of you who can use a new version of C#: // add $ at

CL-WHO-like HTML templating for other languages?

筅森魡賤 提交于 2019-11-27 03:20:56
问题 Common Lisp guys have their CL-WHO, which makes HTML templating integrated with the "main" language thus making the task easier. For those who don't know CL-WHO, it looks like this (example from CL-WHO's webpage): (with-html-output (*http-stream*) (:table :border 0 :cellpadding 4 (loop for i below 25 by 5 do (htm (:tr :align "right" (loop for j from i below (+ i 5) do (htm (:td :bgcolor (if (oddp j) "pink" "green") (fmt "~@R" (1+ j)))))))))) Do you know any libraries like this for other