npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodreports

v0.1.0

Published

A document generator using Open Office Writer Documents as templates.

Downloads

3

Readme

nodreports

License

A document generator using Open Office Writer Documents as templates. Write a document, embed Handlebars tags, and convert. NODReports stands for "Node.js Open Document Reports".

Install

With Node.js:

$ npm install nodreports

Usage

Creating a template

Start Open Office Writer and create a document. This document will be used as a template.

Embed Handlebars tags at any locations you like. For detailed rules, see below. The rules are greatly inspired by JODReports, a document generator written in Java. For detais about Handlebars itself, see Handlebars Home Page.

Inserting an expression

Select from OpenOffice Writer's main menu Insert / Fields / Other... (or press Ctrl+F2) and open Field dialog.

In the dialog, select Functions tab and select "Input field" as field type. Change Reference to "NODScript" and click Insert.

In the next dialog, enter a Handlebars expression and click OK. Use double-stash rather than triple-stash so that XML special characters such as "<" and "&" do not break the structure of the OpenOffice Writer Document. Below is an example of an expression.

{{foo}}

The inserted field will be displayed as a grayed rectangle with the expression in it.

Inserting expressions at special locations

In cases like iterating table rows for each item of a list, you can insert Handlebars expressions at special locations such as before and after a certain OpenOffice XML tag. (Knowlegde about internals of OpenOffice Writer Document Format is required. Hint: unzip an odt file and view unzipped content.xml.)

Select from OpenOffice Writer's main menu Insert / Script and open Edit Script dialog.

In the dialog, change Script Type to "NODScript", enter the script in Text and click OK.

You can insert an expression just before or after an XML element where the script is located. To insert an expression before an XML element, write "@tagName" in one line followed by the expression to be inserted. To insert after an XML element, write "@/tagName" in one line followed by the expression. Thus you can wrap an XML element by a Handlebars block expression. Note that the "tagName"s should contain the namespace. Also note that if more than one element meet the condition, the inner-most one is selected.

Below is an example to iterate a table row over a list. The inner-most table:table-row element containing the script will be repeated for each item of aList.

@table:table-row
{{#each aList}}

@/table:table-row
{{/each}}

API

The module exports class Template.

Load a template by calling Template.load() and passing a stream as an argument. Template#dumyAsync() returns a promise which provides a stream of the generated document.

Below is an example which reads a template from the file system and write the generated document to the file system.

const fs = require('fs')
const nodreports = require('nodreports')
const Template = nodreports.Template

const root = { ... }

const template = Template.load(fs.createReadStream('template.odt'))

template.dumpAsync(root, {
  jszip: {
    streamFiles: true // Not necessary, but requires less memory if set to true
  }
})
  .then(stream => {
    stream.pipe(fs.createWriteStream('out.odt'))
  })

By default, the loaded template has property "engine" which has property "handlebars". You can customize Handlebars module via the property, such as register additional Handlebars helpers.

Below is an example to add an additional helper.

const template = Template.load(fs.createReadStream('template.odt'))
template.engine.handlebars.registerHelper(require('handlebars-helper-eval-js')())

History

version 0.1.0

Released on 2019-5-3

  • initial release

Development

This project uses npm for development.

Try these commands on the top folder of the project.

npm install
npm run build

Author

License

Copyright (c) 2019, recyclebin5385

Released under the BSD 2-Clause License.