https://github.com/losinggeneration/pipeln
A Negroni middleware inspired by Sprockets with Rails.
https://github.com/losinggeneration/pipeln
Last synced: 2 months ago
JSON representation
A Negroni middleware inspired by Sprockets with Rails.
- Host: GitHub
- URL: https://github.com/losinggeneration/pipeln
- Owner: losinggeneration
- License: mit
- Created: 2015-02-16T07:27:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-03-23T23:51:23.000Z (about 9 years ago)
- Last Synced: 2025-03-06T16:41:46.895Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pipeln
This is a negroni middleware inspired by Sprockets with Rails.
Curently it has the following features:
* Asset lookup based on a default (but configurable) layout.
* Processing Javascript //=require & //=require_tree
* Template helpers as convenience functions for script & link tags.
### Example usage
```go
package main
import (
"net/http"
"github.com/codegangsta/negroni"
"github.com/losinggeneration/pipeln"
)
func main() {
mux := http.NewServeMux()
n := negroni.Classic()
n.Use(pipeln.NewAssets())
n.UseHandler(mux)
n.Run(":8080")
}
```
### Middleware
The middleware should be pretty straight forward. You tell negoroni to use pipeln.NewAssets and pass it an optional pipeln/assets.Options to change the directory layout if you want. The base layout NewAssets is expecting is:
```
- assets
|- images
|- javascripts
|- stylesheets
```
### Assets
The assets directory can be searched for assets. It also provides the functionality to process Javscript files to support the
```
//= require
//= require_tree
```
directives.
### Templates
Calling FuncMap and passing an *html.Template as an argument will insert in several helpers to make some head tags for link & script easier. It uses the sprockets-rails names:
```
javascript_include_tag "script" tag_opts ( "attribute" "overrides" )
stylesheet_link_tag "stylesheet" tag_opts ( "attribute" "overrides" )
favicon_link_tag "icon" tag_opts ( "attribute" "overrides" )
tag_opts "attribute" "overrides"
```
tag_opts on the *_tag's are optional.