How to reference a CSS / JS / image resource in JSF?

Introduction The proper way is using <h:outputStylesheet>, <h:outputScript> and <h:graphicImage> with a name referring the path relative to webapp’s /resources folder. This way you don’t need to worry about the context path. Folder structure Drop the CSS/JS/image files in /resources folder of the public webcontent as below (just create one if not already exist at … Read more

Including one erb file into another

ERB templates can be nested by evaluating the sub-template from within <%= %> of the main template. <%= ERB.new(sub_template_content).result(binding) %> For example: require “erb” class Page def initialize title, color @title = title @color = color end def render path content = File.read(File.expand_path(path)) t = ERB.new(content) t.result(binding) end end page = Page.new(“Home”, “#CCCCCC”) puts page.render(“home.html.erb”) … Read more

How to properly render partial views, and load JavaScript files in AJAX using Express/Jade?

Great question. I don’t have a perfect option, but I’ll offer a variant of your solution #3 that I like. Same idea as solution #3 but move the jade template for the _full file into your code, since it is boilerplate and javascript can generate it when needed for a full page. disclaimer: untested, but … Read more

What is a templating language?

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 … Read more

comment foreach binding vs foreach binding in knockoutjs

Use native binding when a parent-child relationship exists within the binding section, like a ul and a li. Use the comment syntax for containerless binding when your binding section does not have a parent-child relationship. In your example you use the first code block because you are not trying to bind to a parent-child structure. … Read more

Best way to handle data attributes in Slim

There are multiple ways in Slim As Hash Attributes which will be hyphenated if a Hash is given (e.g. data={a:1,b:2} will render as data-a=”1″ data-b=”2″) Use it directly as “mu is too short” mentioned, quite intuitive. a data-title=”help” data-content=”foo” Use Ruby code. I often do this and rarely above. = link_to ‘foo’, bar_path, data: {a: … Read more

How can I show just the most recent post on my home page with jekyll?

This can be accomplished through the use of limit: {% for post in site.posts limit:1 %} … Show the post … {% endfor %} You can also use limit and offset together to “feature” your most recent post: <h1>Latest Post</h1> {% for post in site.posts limit:1 %} … Show the first post all big … … Read more