Code Monkey home page Code Monkey logo

martini-bundle's Introduction

martini-bundle

martini-bundle adds resource bundling and minification to Martini.

Build State

wercker status

Getting Started

Install all the packages (go 1.1 and greater is required):

go get github.com/fjdumont/martini-bundle/...

and

import "github.com/fjdumont/martini-bundle/scriptbundle"
import "github.com/fjdumont/martini-bundle/stylebundle"

Components

scriptbundle

martini-bundle/scriptbundle adds concatenation, scope wrapping and minification to your JavaScript files.

  • concatenation: simply concatenates all file contents
  • scope wrapping: wraps an IIFE/IFFY/SIAF around the concatenated scripts
  • minification: uses the Closure Compiler Service REST API to minify your scripts

Simply use scriptbundle.Default(files ...string) as a martini.Handler to register your script files as a bundle:

m := martini.Classic()
m.Get("/js/app.js", scriptbundle.Default(
  "public/js/jquery.js",
  "public/js/app-utils.js",
  "public/js/app.js",
))

Alternatively, plug your own scriptbundle.Options into scriptbundle.Bundle(opts *scriptbundle.Options, files ...string) to customize your optimizations:

type Options struct {
  Wrap   bool
  Minify bool
}

stylebundle

martini-bundle/stylebundle adds concatenation and minification to your Styleseets.

  • concatenation: simply concatenates all file contents
  • minification: uses the CSS Minifier REST API to minify your styles

Use stylebundle.Default(files ...string) as a martini.Handler to compile your styles into a bundle and use them:

m := martini.Classic()
m.Get("/css/app.css", stylebundle.Default(
  "public/js/vendor/bootstrap.css",
  "public/js/vendor/bootstrap-responsive.css",
  "public/js/app.css",
))

Alternatively, plug your own stylebundle.Options into stylebundle.Bundle(opts *stylebundle.Options, files ...string) to customize your optimizations:

type Options struct {
  Minify bool
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.