Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-pate

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pate - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

6

CHANGELOG.md
# CHANGELOG
### 0.0.3
## 0.0.4
- Bux fix: Multi-level XPath selectors
## 0.0.3
- Express view engine support

@@ -6,0 +10,0 @@

18

lib/pate.js

@@ -43,11 +43,15 @@ var libxmljs = require('libxmljs');

function xpathFn(match, token, rootEl) {
var splited = token.trim().split('/');
var retVal = rootEl.get(splited[0]);
var split = token.trim().split('@');
var retVal = rootEl;
if (splited.length < 2) {
var path = split[0].replace(/\/$/, "") || null;
var attr = split[1] || null;
if(path)
retVal = retVal.get(path);
if(attr)
retVal = retVal.attr(attr).value();
else
retVal = retVal.text();
} else {
splited[1] = splited[1].substr(1);
retVal = retVal.attr(splited[1]).value();
}

@@ -54,0 +58,0 @@ return retVal;

{
"name": "node-pate",
"version": "0.0.3",
"version": "0.0.4",
"description": "Simple XPath-oriented, Express-compatible Template Engine",

@@ -5,0 +5,0 @@ "main": "app.js",

![logo](https://raw.githubusercontent.com/benoror/node-pate/master/resources/logo.png)
# About
# About Pâté
Pâté is a simple XPath-oriented, express-compatible template engine for Node.js
Pate (/ˈpæteɪ/) is a simple XPath-oriented, express-compatible template engine for Node.js
# Features
- Support for simple XPath selectors
- Formatting via external lib
- Compatible with Express view engine
# Installation

@@ -15,3 +21,3 @@

Dependencies [source](https://github.com/TooTallNate/node-gyp#installation):
Dependencies ([more info](https://github.com/TooTallNate/node-gyp#installation)):
- **Python**

@@ -26,2 +32,20 @@ - Unix: Python v2.7

**data.xml**:
<data>
<row>
<bread price="42.56">
<name>Bretzel</name>
</bread>
</row>
</data>
**tpl.txt**:
{{ bread/name }} price: $[[ formatMoney({{ bread/@price }}) ]]
([[ moneyToWords({{ bread/@price }}) ]])
**parse.js**:
var fs = require('fs');
var pate = require('node-pate');

@@ -31,4 +55,4 @@ var formatter = require('./format_lib.js');

var options = {
tpl: '{{ bread/@name }} price: $[[ formatMoney({{ bread/@price }}) ]] ([[ moneyToWords({{ bread/@price }}) ]])',
xml: '<data><row><bread name="Bretzel" price="42.56" /></row></data>',
tpl: fs.readFileSync('tpl.txt'),
xml: fs.readFileSync('data.xml'),
xpath: '/*/*',

@@ -42,5 +66,6 @@ format_lib: formatter

Output:
**Output**:
Bretzel price: $42.56 (CUARENTA Y DOS PESOS CON 56/100)
Bretzel price: $42.56
(CUARENTA Y DOS PESOS CON 56/100)

@@ -76,3 +101,3 @@ # Express example

Go to: http://localhost:3000/test
Go to: <http://localhost:3000/test>

@@ -85,4 +110,5 @@ # Status

- No array support
- No array iteration support
- No support for namespaces
- Ugly logo ):

@@ -89,0 +115,0 @@ # Inspirations

LABEL:
ID: Uriel
ID: Benjamin
SEX: Masculino

@@ -22,4 +22,4 @@ /**

pate.parse({
tpl: '{{ count/@type }} count: {{ count }}',
xml: '<data><row><count type="Bretzel">42</count></row></data>',
tpl: 'ROW ID: {{ @id }} -- Object: {{ object }} -- Bread: {{ bread/@type }} (count: {{ bread/count }} {{ bread/count/@unit }})',
xml: '<data><row id="28"><object>Knife</object><bread type="Bretzel"><count unit="pc">42</count></bread></row></data>',
xpath: '/*/*',

@@ -29,3 +29,3 @@ }, function (err, data) {

if(!err) {
expect(data).toEqual("Bretzel count: 42");
expect(data).toEqual("ROW ID: 28 -- Object: Knife -- Bread: Bretzel (count: 42 pc)");
}

@@ -36,3 +36,3 @@ done();

xit("should parse basic Templates and apply data based on XPath placeholders", function (done) {
it("should parse basic Templates and apply data based on XPath placeholders", function (done) {
fs.readFile('spec/fixtures/basic/data.xml', 'utf8', function(err, xml) {

@@ -39,0 +39,0 @@ fs.readFile('spec/fixtures/basic/template.txt', 'utf8', function(err, tpl) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc