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

hpp-hx

v0.0.3

Published

HHP is a type-safe templating system for Haxe greatly inspired by PHP programming language templating possibilities.

Downloads

2

Readme

HHP

HHP is a type-safe templating system for Haxe greatly inspired by PHP programming language templating possibilities. HHP stands for Haxe Hypertext Preprocessor.

In PHP you can use plain PHP code inside of a template. This feature gives you unlimited control of template logic. Thanks to macros we can do the same thing with Haxe, but with additional error detection at compile time!

Features:

  • Use any valid Haxe code inside templates.
  • Compiler's code completion for variables used in template.
  • Compile-time template parsing, which means you will get compiler notifications if:
    • If you try to pass to template a variable which is not used in template.
    • If you're passing a value of wrong type to a template variable.
  • Include templates in templates.

Rules:

  1. In a template use tags <?hhp ... ?> to inline Haxe code. Use this.echo(haxe_expression) in inlined code to add haxe_expression value to output buffer.
  2. Use <?=haxe_expression?> to add value of haxe_expression to output buffer.
  3. Use <?hhp this.render('another/template.html', ...); ?> to include another template (see hhp.Template.render() method description)

Base templates path

If you have all your templates in for example path/to/my/views/templates/ you can set this path as base path for all templates using compiler flag:

--macro hhp.Hhp.basePath('path/to/my/views/templates/')

And omit this common path part in templates.

Examples:

Let's say we have template like this:

<!-- templates/test.html -->
<html>
    <head>
        <title><?=this.title?></title>
    </head>
    <body>
        <ul>
            <?hhp
                for (i in 0...this.listSize) {
                    this.echo('<li>Item #${i + 1}</li>');
                }
            ?>
        </ul>
    </body>
</html>

Notice: inside of a template you must use this to access template variables and methods

Simple way:

var content : String = hhp.Hhp.render('templates/test.html', {
    title : 'Hello, HHP!',
    listSize : 2
});

trace(content);

Advanced way

//MyTemplate.hx
@:hhp('templates/test.html')
class MyTemplate extends hhp.Template {
    /**
    * Add template variable declaration if you want to constraint allowed type or
    *   set default value for this variable.
    * If variable used in template is not declared in a class, it will be Dynamic.
    */
    public var listSize : Int = 5;


    /**
    * You can also add any additional methods and use them in a template.
    */
}


//Main.hx
class Main {
    static public function main () {
        var tpl = new MyTemplate();
        tpl.listSize = 10; //integer variable
        tpl.| //get code completion with variables: title, listSize

        var content : String = tpl.execute();
        trace(content);
    }
}