Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 1.12 KB

README.md

File metadata and controls

33 lines (23 loc) · 1.12 KB

wintersmith-xmlb

A template plugin for the Wintersmith static site generator that lets one to write xmlb templates to generate XML.

The xmlb template library uses the xmlbuilder-js library to generate XML.

My need for outputting XML was to generate a sitemap file. It could also be used to generate RSS and Atom feeds.

Here's an example of a snippet of a sitemap.xmlb template:

//set up pages array

var root = xml.begin('urlset', {version: '1.0', encoding: 'UTF-8'})
              .att('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')

pages.forEach(function(item){
  root.ele('url')
        .ele('loc')
          .text(locals.url + item.url)
        .up()
        .ele('changefreq')
          .text('weekly')
});

Referenced projects

A special thanks to the wintersmith-ejs project by Stephen Allred, which I used as the template for this project.