proxy

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

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

Go to latest
Published: Oct 7, 2014 License: MIT Imports: 2 Imported by: 14

README

Ace Proxy

wercker status GoDoc Coverage Status

Overview

Ace Proxy is a proxy for the Ace template engine. This proxy caches the options for the Ace template engine so that you don't have to specify them every time calling the Ace APIs.

Usage

package main

import (
	"net/http"

	"github.com/yosssi/ace"
	"github.com/yosssi/ace-proxy"
)

var p = proxy.New(&ace.Options{
	BaseDir:       "views",
	DynamicReload: true,
})

func handler(w http.ResponseWriter, r *http.Request) {
	tpl, err := p.Load("base", "", nil)

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if err := tpl.Execute(w, map[string]string{"Msg": "Hello Ace"}); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":8080", nil)
}

Documentation

Overview

Package proxy provides a proxy for the Ace template engine. The proxy caches the options for the Ace template engine so that you don't have to specify them every time calling the Ace APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	Opts *ace.Options
}

Proxy represents a proxy for the Ace template engine.

func New

func New(opts *ace.Options) *Proxy

New creates and returns a proxy.

func (*Proxy) Load

func (p *Proxy) Load(basePath, innerPath string, opts *ace.Options) (*template.Template, error)

Load calls the `Load` function of the Ace template engine.

Jump to

Keyboard shortcuts

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