Dropwizard View includes several Freemarker templates - freemarker

I use the Views with Freemarker to Display HTML info pages. Now I want to add a "footer" for all templates, but I dont want to copy same code to every *.ftl file.
Is it possible to create one footer.ftl and add it to all other *.ftl files? Searching web, i found freemarker macros, but I dont know how to use it in DW. How can I use freemarker macros with DW?
This doesn't help -> How can I embed one DropWizard (with freemarker) View in another one?

I added just this line to the original ftl:
<p><#include "footer.ftl"> </p>
This file is in the same folder (I havent tried other locations) and contains the footer text like:
Copyright 2001-2002<br>
All rights reserved.

Related

How to create a simple webpage using Oracle WebCenter Sites

I am new to WCMS. I need help in creating a brand new website using Oracle WebCenter Sites with more customization.
I have created the templates and pages. How do I use the assets and call the page attribute and its value in the templates?
How do I render the templates?
How do I use the assets and call the page attribute and its value in the templates?
You have to load the page asset itself first so that you get all the attributes and later you can load each attribute and display their values respectively.
<asset:load name="anyName" type='<%=ics.GetVar("c")%>' objectid='<%=ics.GetVar("cid") %>' flushonvoid="true" />
<asset:scatter name="nameAssignedOnAssetLoad" prefix="asset" />
<ics:getvar name="asset:attribute_name" />
Above code snippet loads the Page asset and now you can load individual attributes using asset:load tag (if they are basic asset type attributes) or assetset:setasset tag (if they are flex asset type attributes).
If you are more comfortable with Java, you can use OWCS Java API and follow these steps mentioned in Developers Guide
How do I render the templates?
To render a template you have to use render:calltemplate tag with appropriate attributes. This tag invokes your template, basically the code/logic that you have written within the template.
As you're new to OWCS I will suggest you to go through basic examples of read and write as mentioned in Developers Guide, they will help you a lot.
Oracle has dedicated OWCS Community wherein your queries will be answered must faster!

What is the best practice for placing template views and backbone view code

I am creating a ASP.Net MVC 3 application using Backbone.js. I am also using the jQuery templates for the views.
My question is how do I organize the files in an efficient way?
Currently I have a XXX.js file for the backbone application and inlined templates stored in the page that shows the backbone application, Index.cshtml. How can I move the templates into a different file that I can include like I include XXX.js?
App/
Scripts/
backbone.js
underscore.js
jquery-1.6.4.js
jquery.tmpl.js
myBackboneApplication.js
Views/
Home/
Index.cshtml
Controllers/
HomeController.cs
I would like to move the templates out of Index.cshtml and into something related to myBackboneApplication.js. Something that I can include as a file inside Index.cshtml instead of inlined.
You might check out this related question. The two basic options are:
Create your templates as strings and include the Javascript file in your index file.
Create your templates as HTML in separate files, and insert them into the index file at build time, most likely within <script type="text/template"> tags.
In my current Backbone.js project, I'm using the second option - I keep all my templates in a separate folder, and I insert them into my index file during my ant build. Each template (e.g. my-view-template.html) is inserted into a <script> tag with id="my-view-template", and then I use jQuery to create the templates using $("#my-view-template").html() as the template string.

MVC sitemap provider & css styling

Does anyone know how to customise the rendering of the MVC sitemap provider so my ul element has a specific css class?
Try MvcSiteMapProvider hosted on CodePlex. You should be able to fairly easily migrate your existing Sitemap file to the slightly different but essentially compatible format. This will give you the ability to output your sitemap using the simple Html.MvcSiteMap().SiteMap() helper method.
The source of the project includes the default templates which you can edit to produce any rendering you like...or just pass in the name of a template in accordance with MVC convention. The model types you'll be rendering are SiteMapHelperModel, SiteMapNodeModel and SiteMapNodeModelList (namespaces removed for terseness).
I appreciate this may not be exactly what you're after as it relies on a 3rd party tool but its a useful project that supports much more than just rendering sitemaps. You'll want version 3.0.0 for MVC3.
Dan

Embedded views and resources (mvc)

I've embedded several views in a library so that I can re-use across projects using this method which works OK:
http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/
But one view usings a Javascript file. I've tried marking this as an embedded resource and adding it AssemblyInfo.cs and then referencing this resource using
<%= ClientScript.GetWebResourceUrl(this.GetType(), "FullPath.FileName.js")%>
This is literally displaying this output in the view
WebResource.axd?d=nUxqfqAUQLabLU54W
I think this is because Im trying to refer to an embedded resource from an embedded resource.
Help appreciated as Im going round in circles..
Steve
The problem here was with my call to GetWebResourceUrl. I've changed the format to that below and it works fine :)
<script src="<%= ClientScript.GetWebResourceUrl(typeof(Opal.Web.Shared.AClassInMyAssembly), "FullPath.FileName.js")%>" type="text/javascript"></script>
So Ive contained the call in a script tag and changed the type parameter.

Which template engine and Ajax framework/toolkit can load templates from JAR files?

Which Template-Engine and Ajax-Framework/-Toolkit is able to load template information from JAR-Files?
If you mean server-side template engines, you can get Velocity to load its templates from the classpath (which includes JAR files). Check out the section "Configuring the Resource Loaders (template loaders)" in the Developer Guide.
Take a look at http://www.ztemplates.org which is simple and easy to learn. This one allows you to put all related templates, javascript and css into one jar and use it transparently. Means you even have not to care about declaring the needed javascript in your page when using a provided component, as the framework does it for you.

Resources