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

nsp-jstl-taglib

v0.2.4

Published

NSP taglib for JSTL Jakarta Standard Tag Library

Downloads

75

Readme

nsp-jstl-taglib

Node.js CI npm version

NSP taglib for JSTL Jakarta Standard Tag Library

  • JSTL core library - e.g. <c:if test="${test}"></c:if>
  • JSTL formatting library - e.g. <fmt:formatDate value="${date}" pattern="yyyy-MM-dd"/>
  • JSTL functions library - e.g. ${ fn:toUpperCase("abc") }
  • See TypeScript declaration files for API detail.

SYNOPSIS

import {createNSP} from "nsp-server-pages";
import {cTags, fmtTags, fnFunctions} from "nsp-jstl-taglib";

const nsp = createNSP();

nsp.addTagLib({ns: "c", tag: cTags});
nsp.addTagLib({ns: "fmt", tag: fmtTags});
nsp.addTagLib({ns: "fn", fn: fnFunctions});

const context = {title: "nsp", upper: true};

const render = await nsp.loadJSP("path/to/template.jsp");

const html = await render(context);

console.log(html);
// => <h1>NSP</h1>

<c:if test="${upper}">
  <h1>
    <c:out value="${fn:toUpperCase(title)}" default="Untitled"/>
  </h1>
</c:if>

COMMONJS

  • Both ES Modules and CommonJS supported.
const {createNSP} = require("nsp-server-pages");
const {cTags, fmtTags, fnFunctions} = require("nsp-jstl-taglib");

COMPATIBILITY

JSTL core library

| tag | status | note | |-----------------|--------|--------------------------------------------------| | <c:choose> | 👍 OK | | | <c:if> | 👍 OK | | | <c:import> | 👍 OK | | | <c:forEach> | 👍 OK | | | <c:forTokens> | 👍 OK | | | <c:out> | 👍 OK | | | <c:otherwise> | 👍 OK | | | <c:param> | 👍 OK | | | <c:redirect> | 🚫 N/A | not available by design | | <c:remove> | 👍 OK | | | <c:set> | 👍 OK | | | <c:url> | 👍 OK | | | <c:when> | 👍 OK | |

scope="xxx" attribute is just ignored as nsp supports only request scope.

JSTL formatting library

| tag | status | note | |-------------------------|------------|-------------------------------------------| | <fmt:requestEncoding> | 👍 OK | | | <fmt:setLocale> | 👍 OK | | | <fmt:timeZone> | 👍 OK | | | <fmt:setTimeZone> | 👍 OK | | | <fmt:bundle> | 👍 OK | implement ResourceBundle.getBundle hook | | <fmt:setBundle> | 👍 OK | implement ResourceBundle.getBundle hook | | <fmt:message> | 👍 OK | | | <fmt:param> | 👍 OK | | | <fmt:formatNumber> | 👍 OK | works mostly. some feature still missing | | <fmt:parseNumber> | 👍 OK | | | <fmt:formatDate> | 👍 OK | works mostly. some feature still missing | | <fmt:parseDate> | 🕑 Not yet | |

Implement ResourceBundle.getBundle hook which returns an array of key-value pair properties. The hook is called by <fmt:bundle> and <fmt:setBundle> tags.

const nsp = createNSP();

nsp.hook("ResourceBundle.getBundle", async (basename) => {
    const properties = {"key": "value"};
    return [properties];
});

JSTL functions library

| function | status | equivalant method | |--------------------------------|--------|----------------------| | ${ fn:contains() } | 👍 OK | String#includes | | ${ fn:containsIgnoreCase() } | 👍 OK | | | ${ fn:endsWith() } | 👍 OK | String#endsWith | | ${ fn:escapeXml() } | 👍 OK | | | ${ fn:indexOf() } | 👍 OK | String#indexOf | | ${ fn:join() } | 👍 OK | Array#join | | ${ fn:length() } | 👍 OK | | | ${ fn:replace() } | 👍 OK | String#replace | | ${ fn:split() } | 👍 OK | String#split | | ${ fn:startsWith() } | 👍 OK | String#startsWith | | ${ fn:substring() } | 👍 OK | String#substring | | ${ fn:substringAfter() } | 👍 OK | | | ${ fn:substringBefore() } | 👍 OK | | | ${ fn:toLowerCase() } | 👍 OK | String#toLowerCase | | ${ fn:toUpperCase() } | 👍 OK | String#toUpperCase | | ${ fn:trim() } | 👍 OK | String#trim |

LINKS

  • https://github.com/kawanet/nsp-server-pages
  • https://github.com/kawanet/nsp-jstl-taglib
  • https://github.com/kawanet/nsp-struts1-taglib
  • https://github.com/kawanet/nsp-seasar2-taglib
  • https://github.com/apache/tomcat-taglibs-standard/
  • https://github.com/apache/tomcat-taglibs-standard/tree/main/impl/src/main/java/org/apache/taglibs/standard
  • https://github.com/apache/tomcat-taglibs-standard/tree/main/impl/src/main/resources/META-INF

LICENSE

// SPDX-License-Identifier: Apache-2.0