With templates a user can customize how the blog entry is previewed before publishing. So instead of plain text, the preview tab will show

To use a template for preview in JBlogEditor, go to File | Blog Properties and check Use Template. By default JBlogEditor comes with one basic template. However its very easy to create custom templates to make the preview look like your blog.

Velocity template engine is used to generate the HTML for preview. If you not familier with Velocity, think of it as token replacement (Velociy is much more powerful, but for now JBlogEditor uses it like a token replacement engine). Each blog type supports certain set of tokens. A template is composed of normal HTML and these tokens. Just before preview is done, these tokens are replaced with their actual value and the generated html shown in the preview.

The template is made available is JBlogEditor by creating the template file in the C:\Documents and Settings\<username>\.jblogeditor\<blog name> directory. So in my case it is C:\Documents and Settings\lokeshshah\.jblogeditor\lokeshshah-wpBlog. (For those familiar with Eclipse, .jblogeditor is the default workspace used by JBlogEditor). The template file is must be named template.vm.

Here’s a simple template file:
[html]$title
body {
background:#859EB2;
margin:0;
text-align:center;
color: #ffffff
}
#blog-title {
width:660px;
background:#FF7F00;
margin:20px auto 0px;
font-size:200%;
padding:30px;
}
#content {
background:#0062B2;
width:660px;
margin:0px auto;
padding:30px;
text-align:left;
}
#date {
font-size:80%;
font-weight:normal;
}
#entry-title {
font-size:120%;
border-bottom:1px dotted #ccc;
}

$title

$entryDate

$entryTitle: by $user

$entryBody

[/html]

There are some special token that I have used in the html above: $title, $entryTitle, $entryDate, $entryBody, $user. These tokens are replaced by their actual values taken from the entry being previewed.

That’s all there is to creating new templates. Just relaunch JBlogEditor and start enjoying the new preview functionality.

Advertisements