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

vite-plugin-freemarker

v1.2.0

Published

[Vite](https://github.com/vitejs/vite) plugin for [freemarker](https://freemarker.apache.org/).

Downloads

10

Readme

vite-plugin-freemarker

Vite plugin for freemarker.

This plugin was inspired by vite-plugin-twig and vite-plugin-handlebars.

Installation

npm i -D vite-plugin-freemarker

Usage

/* vite.config.js */
import freemarker from 'vite-plugin-freemarker'

export default {
  plugins: [
    freemarker()
  ]
}

Options

The plugin can be configured both via the freemarker.config.js file from the project root or by passing a configuration object directly as argument to the function above (in this last case, the configuration file will be ignored).

Templates

The html files located by default in the Vite project root are not intented to be replaced directly by the freemarker ones as the normal page files resolution/linking on the Vite's dev server is wanted to be preserved along with the build logic. However, those files are supposed to contain a json definition instead of the traditional markup, which should be moved on the freemarker side.

More in details, a html file should look like this:

<!-- index.html -->
<script type="application/json">
  {
    "template": "path/to/template.ftl",
    "data": {
      "title": "Homepage"
    }
  }
</script>

where template is the path of the freemarker template to be rendered (relative to the cwd), and data is the local context for that page (eventually merged with the globals provided via plugin options).

ℹ️ The script tag is not mandatory, since a plain text representation of the json will be correctly parsed too. However, it is recommended for readability and syntax highlighting purposes.