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

grunt-codekit

v1.2.1

Published

Grunt plugin that compiles Kit files

Downloads

154

Readme

grunt-codekit

Grunt plugin for compiling Kit files Can be used to embed files or concatenate files

NPM version Build Status PR time] Issue time]

Getting Started

Install the plugin

npm install grunt-codekit --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-codekit');

Choose files to compile

The plugin supports compiling templates written using the Kit language of CodeKit™. You can use both short form and long form when specifying input and output destination.

Using short form (see below), the output files will be placed in the dest directory and have the same names as the input files, only using a .html extension. When using the long form you can explicitly specify the full name and path of each output file.

There is nothing in the way of mixing and matching the two styles.

Configuration options

As with all Grunt plugins, you can specify an options object, either for all tasks or for each task. There is currently just one option:

  • compilePrefixed - Files starting with an underscore (such as _header.kit), so called partials, are normally not considered for compilation. By setting this option to true you can override this setting and still compile these files (default false).

Do remember that Grunt has a [lot of fancy ways of doing file system manipulation] (http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically) for you

Example configuration

grunt.initConfig({
  codekit: {
  
    globbed_example_config : {
        src : 'templates/**/*.kit',
        dest : 'build/html/'
    },
    
    explicit_output_names: {
      files : {
        'build/index.html' : '/templates/my_special_index.kit'
      }
    },
    
    build_with_underscored_files : {
        options : { compilePrefixed : true },
        files : {
            'build/about.html' : '_about.kit',
            'build/index.html' : '_index.kit'
        }
    },

    // see http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
    dynamic_file_object: {
        files: [{
            expand: true,
            cwd: 'sources',
            src: ['**/*.kit'],
            dest: 'build',
            ext: '.html'
    }
});

Example usage: embedding critical path CSS

Using Penthouse one can generate a file containing the critical path css, which can dramatically impact your site's perceived speed and your page ranking in Google.

You still need a way of embedding that CSS, though, and one way of doing that is using the Kit language. An example on how this kit file might look is as follows

<html>
<head>
<title><!-- @title --></title>

<!-- embed critical path css generated by penthouse -->
<style>
<!--@include critical.css -->
</style>

</head>
<body>
    <!-- @include _header.kit -->
    <!-- @include _navbar.kit -->
    The main text of the page
    <!-- @include _footer.kit -->
</body>
</html>

About the Kit language

The Kit language is a simple html templating language used in the commercial program CodeKit. It imports files into other html files and does simple variable substitution. Since Bryan Jones made it open source it has seen support from several other programs, among those PrePros and implementations in Python and Javascript. This plugin makes it possible to compile these files using Grunt.

Release History

  • 0.1.0 First release. Compilation of Kit files using an embedded python module.
  • 0.2.0 Removed dependency on Python.
  • 0.3.0 Partials are now being excluded.
  • 0.4.0 Added support for CodeKit/PrePros javascript concatenation directives.
  • 1.0.0 Added globbing support and removed support for javascript compilation.