bottle

package module
v0.0.0-...-cb711c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2015 License: MIT Imports: 8 Imported by: 0

README

===============================================================================
cidre-bottle: building a packaged cidre webapp binary
===============================================================================

.. image:: https://godoc.org/github.com/yuin/cidre-bottle?status.svg
    :target: http://godoc.org/github.com/yuin/cidre-bottle

|

cidre-bottle provides an easy way to build a fat binary for web applications using the `cidre <https://github.com/yuin/cidre/>`_ webframework.

----------------------------------------------------------------
Installation
----------------------------------------------------------------

.. code-block:: bash
   
   go get github.com/jteeuwen/go-bindata/...
   go get github.com/elazarl/go-bindata-assetfs/...
   go get github.com/yuin/cidre-bottle

----------------------------------------------------------------
Usage
----------------------------------------------------------------

directory structure::
    
    +- assets
       +- templates
          +- page.tpl
          +- layout.tpl
       +- statics
          +- css
             +- app.css
          +- js
             +- app.js
          +- img
             +- logo.png

Runs a `go-bindata` command.

.. code-block:: bash
    
    go-bindata assets/...

Modify cidre app codes.

.. code-block:: go

    app := cidre.NewApp(appConfig)
    // Set a renderer with a go-bindata support
    app.Hooks.Add("setup", func(w http.ResponseWriter, r *http.Request, data interface{}) {
        app.Renderer := bottle.NewHtmlTemplateRenderer(app.Renderer, Asset, AssetDir)
    })

    root := app.MountPoint("/")
    // Serve static files
    bottle.Static(root, "statics", "statics", "assets/statics", Asset, AssetDir)

----------------------------------------------------------------
License
----------------------------------------------------------------
MIT

----------------------------------------------------------------
Author
----------------------------------------------------------------
Yusuke Inuzuka

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Static

func Static(mt *cidre.MountPoint, n, p, local string, asset func(string) ([]byte, error), assetdir func(string) ([]string, error), middlewares ...interface{})

Types

type HtmlTemplateRenderer

type HtmlTemplateRenderer struct {
	*cidre.HtmlTemplateRenderer
	Asset    func(string) ([]byte, error)
	AssetDir func(string) ([]string, error)
}

func NewHtmlTemplateRenderer

func NewHtmlTemplateRenderer(r cidre.Renderer, asset func(string) ([]byte, error), assetdir func(string) ([]string, error)) *HtmlTemplateRenderer

func (*HtmlTemplateRenderer) Compile

func (rndr *HtmlTemplateRenderer) Compile()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL