I want to build a blog with krakenjs and want to use the i18n feature from it (makara): https://github.com/krakenjs/makara
Makara requires to put all locales into static files. eg. locales/US/en/
How can I use it with dynamic content from e.g. contentful.com
Here's the excerpt from the makara readme that explains how to do this:
If you have runtime values to be inserted, use dust brace to select the value from the dust template context as in the index.greeting line. Note that there is no restriction on inserting HTML tags into the messages. They are just another string of characters as far as the content processing is concerned.
So you would have a property like so:
index.dynamic={dynamicConent}
The value of dynamicContent will be picked up at run-time from the dust template context.
Related
Using Node.js and express in a MEAN environment, I am looking for a simple and straightforward template engine, meeting these requirements:
does not dictate me to only use its own weird syntax but allows me to keep writing webpages using pure/plain html and js
supports conditional includes
works with express
operates on server-side (Node.js/Express)
executes freakin' fast ;)
Basically I just want to slice my webpage into several modules (e. g. header, footer, ...) and include those now and then based on simple conditions. I don't want to entirely (re-)rebuild all webpages using a proprietary template language but rather prepare a few html modules that I concatenate at runtime (comparable to PHP where I just use the include instruction to paste prepared html code).
I had a look at http://garann.github.io/template-chooser/ and https://github.com/nodejs/node-v0.x-archive/wiki/modules#templating but the sites seem outdated and according to them, there ain't no template engine available fully meeting my requirements!?
Suggestions anyone?
I think ejs is more natural for what you are looking for https://scotch.io/tutorials/use-ejs-to-template-your-node-application, but jade can work also. The example in the link uses partials, which you dont need to use if ur just rendering a single page
I'd like to accomplish something in jade, but not sure on the best approach. I want to have several product pages on a website, and most of these product pages will have the same layout and design, so I'm going to create one jade template. However, I would love to be able to insert some custom HTML for a couple of product pages in particular.
Can I use an include or something to optionally add custom HTML?
You could use jade partials to show different snippets depending on some conditions in the templating context:
if user.description
!=partial(template name[, options])
Or you might use template inheritance and render a different template depending on the same conditional, but this time in your controller. I would probably do the latter.
I´m trying to understand how the use of the stash plugin will affect the URls of my site.
The traditional way:
I have a template group called site. Within the TG site I have the templates articles, about_us, etc.
The URl will for a single entry be
www.mysite.com/index.php/site/articles/title_of_respective_article
URL for the About-us-page:
www.mysite.com/index.php/site/about_us
Both will reflect the template_group/template structure and thus be SEO-friendly and give users a hint where they are on the site.
But when I use stash I will have 2 wrappers (one for the homepage and one for the rest of the site.
Partials will be used for header, main content and footer.
As far as I understand it, I´ll use the template_groups layout for the wrappers and partials for the main content.
The templating look like
Two wrappers build the TG "layout" Both are hidden, since they should´nt be called directly.
layout
.homepage
.site
Three partials in the TG partials
partials
header
main_content
footer
And by the way shouldn´t those not also be hidden, since they aren´t complete HTML-pages either.
This is what confuses me. How do I get my nice URLs back?
A URL like
www.mysite.com/index.php/site/about_us
will not match the TG/T concept anymore.
Any help?
To expand on both their answers above, and just to be specific to your www.mysite.com/index.php/site/about_us request:
You'd create a template group called "site" and then you may alternatively have something like this code in the /index template
{embed="layout/.site"}
{exp:channel:entries limit="1" disable="categories|member_data|pagination"}
{exp:stash:set name='title'}{title}{/exp:stash:set}
{exp:stash:set name='maincontent'}
<section>
<h1>{title}</h1>
<article>{content}</article>
</section
{/exp:stash:set}
{/exp:channel:entries}
The embed calls the .site layout and the interior simply pulls your specific channel:entries data.
As you can see, it's still using the traditional templategroup/template ways of building URLs, it's just pulling data differently.
When using Stash and the template partials approach (which I don't use personally), the files you mention are all embedded. You still use the same template groups and template files as before.
The Stash-based approach is simply a different way of doing things within your existing templates - not a replacement for them.
Exactly as Derek says. The way to think about it is this - with the template partials approach, your templates contain mostly (if not only) the entries logic (channel entries loop, its parameters, what custom fields are in play for that channel, etc). The outcome of the logic gets stores as stash variables. The stash variables then get called upon by your embedded layout templates to display the content you've stashed. So your URL structure remains the same, but you have considerably less duplication of effort since the more you constrain your templates to logic (i.e. very little if any formatting/display markup) the cleaner they are and the easier it then is to manage your templates.
It is possible to open a Lotus Notes Composite Application (CA) using a syntax like this:
cai:///uniqueappid/uniquepageid?hint
According to a wiki-article -
Passing context to components when opening composite applications - you can pass a Dynamic property to a Composite Application and let the components in the CA read it.
The article has an example like this:
String[] values = data.getPreference("com.ibm.portal.app.input.NiklasTest");
Which should be able to read the parameter from a URL formatted like this:
cai:///uniqueappid/uniquepageid?hint&NiklasTest=xxxxx
I am looking for what my options are in order to get a handle on such a property.
Coding a java component. It seems likely that this would work.
Coding an xPage component. Would it be able to get a handle on the Dynamic
Property?
Coding a Portlet component. Would it be able to get a
handle on the Dynamic Property?
Coding a NSF form- or page-based
component. Are there LotusScript or #functions that can get a handle
on the Dynamic Property?
I am not looking for the best soloution. I am looking for a list of options that are known to work. Basically weeding out in my list above.
I know nothing of Composite Applications, and what exactly is a Dynamic Property, but in an XPage you can simply use param.NiklasTest in order to get the xxxxx from the URL.
In a application where we needed to pass parameters (and be able to open the CA multible times).
The (easy) solution was to build the .ca file on the fly (and embed the parameters) and then launch it.
You can build the template for the .ca file with the designer
IBM Wiki
This article seems to suggest that there such things as include templates. I've made the obvious Google searches but didn't find any documentation.
What are they?
From the Express guide:
The Express view system has built-in support for partials and
collections, which are “mini” views representing a document fragment.
For example rather than iterating in a view to display comments, we
could use partial collection.
So when you have the same "view" for a user in multiple pages, it's more useful to have that view stored in a file and "include" it everywhere. (DRY - Don't Repeat Yourself)
Another example is when have the same layout everywhere and you want to include the rest of the page (for example you could include different headers, footers and body depending on the page).
Here's a good example with Jade, provided in the Express samples:
https://github.com/visionmedia/express/tree/master/examples/jade/views
https://github.com/visionmedia/jade
It's there in one of the H2 headings.