# xslt-templates

> Use XSLT as a template engine for Node

Latest version **1.0.1** (published 2015-05-17) · gpl-2.0 license · 0 weekly downloads

## Install

```sh
npm install xslt-templates
pnpm add xslt-templates
yarn add xslt-templates
bun add xslt-templates
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-05-17 |
| First published | 2015-02-14 |
| Weekly downloads | 0 |
| License | gpl-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nanymor |
| Maintainers | nanymor |

## Links

- npm: https://www.npmjs.com/package/xslt-templates
- npm.io page: https://npm.io/package/xslt-templates

## Dependencies (2)

- [easyxml](https://npm.io/package/easyxml.md) https://github.com/nanymor/node-easyxml/tarball/master
- [libxslt](https://npm.io/package/libxslt.md) ^0.4.1

## Recent versions

- 1.0.1 (latest) — 2015-05-17
- 1.0.0 — 2015-02-14

## README

# xslt-templates
An Express-compatible XSLT rendering engine

**This is very much alpha-state, no tests yet, use it at your own risk...**

Allows to do stuff like:

    var express = require('express'),
        xslt = require('xslt-templates')
        app = express(),
        port = 8000;
    
    // assign the xslt engine to .xslt files
    var opts = {
        xsl: {
            stripXML: true
        }
    }
    
    app.engine('xslt', xslt(opts));
    
    // set .xslt as the default extension
    app.set('view engine', 'xslt');
    app.set('views', __dirname + '/templates/pages');
    
    app.get('/', function(req, res){
        res.locals = {
            params: {
                'current-page': 'home'
            },
    
            users: [
    
                {
                    _id: 123,
                    name: "Andrea",
                    nick: "nany"
                },
                {
                    _id: 222,
                    name: "Someone",
                    nick: "smn"
                },
                {
                    _id: "abc",
                    name: "Me",
                    nick: "mmmm"
                }
            ]
    
        };
        res.render('index');
    }); 
    
    
    app.listen(port);
    console.log('Express server listening on port ' + port);
    
Behind the scene the json context is converted to XML using the excellent [easyxml](https://github.com/tlhunter/node-easyxml)  library:

    <?xml version='1.0' encoding='utf-8'?>
    <data>
      <params>
        <current-page>home</current-page>
      </params>
      <users>
        <user id="123">
          <name>Andrea</name>
          <nick>nany</nick>
        </user>
        <user id="222">
          <name>Someone</name>
          <nick>smn</nick>
        </user>
        <user id="abc">
          <name>Me</name>
          <nick>mmmm</nick>
        </user>
      </users>
    </data>
    
Transformation is handled by [node-libxslt](https://github.com/albanm/node-libxslt)

---
_Source: https://npm.io/package/xslt-templates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
