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

karma-ng-hamlet2js-preprocessor

v0.1.3

Published

A karma plugin to compile Hamlet HTML templates to JavaScript on the fly.

Downloads

4

Readme

Karma Hamlet Angular Preprocessor

This package provides a Karma preprocessor for Hamlet that converts the Hamlet templates into javascript. The javascript inserts the generated HTML into the AngularJs template cache. It provides similar functionality as karma-ng-html2js-preprocessor.

The yesod-static-generators package has an example application using this preprocessor.

Usage

First, configure Karma to use the preprocessor similar to the html2js preprocessor, i.e. inside karma.js.conf

#!javascript
module.exports = function(config) {
    config.set({
        ...

        files: [
            ...
            "somedir/*.hamlet",
            ...
        ],

        plugins: [
            "karma-*",
        ],

        preprocessors: {
            ...
            "**/*.hamlet" : ["ng-hamlet2js"],
        },
    });
};

The preprocessor works by executing runghc with a short script which calls hamletTestTemplate from the Yesod.EmbeddedStatic.AngularJavascript module from the yesod-static-angular package. This package must either be installed globally, installed inside a cabal sandbox which is located in some ancestor of the current directory, or runghc must be configured explicitly below.

Configuration

Configuration options can be specified inside karma.conf.js inside a ngHamlet2JsPreprocessor key, i.e.

#!javascript
module.exports = function(config) {
    config.set({
        ...
        ngHamlet2JsPreprocessor: {
            runghc: "/path/to/custom/runghc",
            ...
        },
    });
};

The following configuration options are supported:

  • runghc (string) path to custom runghc executable. Defaults to searching for runghc on the path.
  • packageDb (string) path to a Haskell package database (which should contain the yesod-static-generators package). If this option is not given, the current directory and then successive parent directories are searched for a cabal.sandbox.config file. If a sandbox config file is found, it is parsed for the package database. If no sandbox config file is found, no package database is used.
  • extraGhcArgs (array of strings) list of extra arguments to pass to runghc. These arguments are used in addition to the package database options.
  • hsProg (string) the Haskell program to be given to runghc with %s in place of the Hamlet filename. The program should read the hamlet from the given file and print the output onto standard output. The primary intent of overriding this is if the Hamlet template uses variable/type safe route interpolation so that you need to define custom variables or setup before calling hamletTestTemplate. The default program is the following:
#!haskell
import qualified Data.ByteString.Lazy as BL
import Yesod.EmbeddedStatic.AngularJavascript (hamletTestTemplate)
main = BL.putStr $(hamletTestTemplate "%s")