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

mapfile-ejs

v3.0.1

Published

Allows you to use Embedded JavaScript (EJS) into MapServer Mapfiles.

Downloads

21

Readme

mapfile-ejs

The module mapfile-ejs allows you to use Embedded JavaScript (EJS) into MapServer Mapfiles.

Installation

  1. Install Node.js and npm from https://nodejs.org/
  2. Install mapfile-ejs with npm install mapfile-ejs -g

Getting started

Use the file extension *.emap for MapServer Mapfiles with EJS. If you watch a directory, all *.emap files will be rendering to *.map files.

Terminal

Usage: emap [options]

  Options:
    -h, --help                     Output usage information
    -V, --version                  Output the version number
    -d, --directory <string>       Input directory of mapfiles with EJS (*.emap) (default: current directory)
    -i, --inputEncoding <string>   Encoding of input mapfiles with EJS (default: utf8)
    -o, --outputEncoding <string>  Encoding of output mapfiles without EJS (default: utf8)
    -r, --ignoreInitial            Ignore rendering of mapfiles with EJS on initial (default: false)
    -e, --eFiles                   Render all e files like *.exml, *.ecss (default: false)

  Examples:
    Start watching and rendering with default options:
      $ emap

    Start watching and rendering with custom options:
      $ emap -d ./examples -i iso-8859-1 -o iso-8859-1 -r -e

JavaScript

Render a file:

import { render } from 'mapfile-ejs';

(async () => {
  // render file with default options
  await render(
    `./template__utf8.emap`,
    `./template__utf8.map`
  );
  
  // render file with custom options
  await render(
    `./template__iso_8859_1.emap`,
    `./template__iso_8859_1__02.map`,
    { inputEncoding: `ISO-8859-1`, outputEncoding: `ISO-8859-1` }
  );
})();

Watch a directory:

import { watch } from 'mapfile-ejs';

// watch a directory with default options
watch(`dir1`);

// watch a directory with custom options
watch(`dir2`, {
  inputEncoding: `utf8`,
  outputEncoding: `utf8`,
  eFiles: false,
  ignoreInitial: false
});

More details are available at the API Documentation and at the examples directory

Mapfile

Input (example.emap):

MAP
<%
  //Loop to create 3 layers
  for(let i = 0; i < 3; i++) {
-%>
  LAYER
    NAME "layer_<%- i %>"
  END
<%
  } //End of loop
-%>
END

Output (example.map):

MAP
  LAYER
    NAME "layer_0"
  END
  LAYER
    NAME "layer_1"
  END
  LAYER
    NAME "layer_2"
  END
END

How to use require and include:

<%
// import is available like
const path = await import(`node:path`);
-%>

<%
// include is available (include_file.ejs) like
-%>
<%- await include('include_file', { }); %>

Developer

Run cli during development:

npm run emap -- -d ./examples/watch/dir1

Run examples:

node examples/isTemplate/index.js
node examples/render/index.js
node examples/watch/index.js

Changelog

v3.0.1

  • Fix mistakes in README.md (2023-04-28)

v3.0.0

  • Update dependencies (2023-04-27)
  • Switch from require()to import() (2023-04-27)
  • Switch render() to async render() (2023-04-07)
  • Remove api documentation (2023-04-27)
  • Remove ESLint configuration file .eslintrc.js (2023-04-27)

v2.0.7

  • Update dependencies

v2.0.6

  • Fix npm bug

v2.0.5

  • Change npm publisher

v2.0.4

  • Update dependencies

v2.0.3

  • Update dependencies

v2.0.2

  • Update mistaks in README.md

v2.0.1

  • Fix log bugs in the cli tool emap
  • Addexamples in README.md

v2.0.0

  • Add API Documentation docs/api
  • Add changelog docs/changelog
  • Add ESLint configuration file .eslintrc.js
  • Add Visual Studio Code configuration .vscode/settings.json
  • Restructure code in src directory
  • Add npm script npm run cli -d ./examples/watchDir/dir1
  • Update dependencies
  • Switch from class MapfileRenderer to module with render() and watch() function
  • Add isTemplate() function
  • Add new examples

License

MIT