ego

package module
v0.0.0-...-9b4763a Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2015 License: MIT Imports: 5 Imported by: 0

README

===============================================================================
cidre-ego: an ego integration for the cidre web framework
===============================================================================

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

|

cidre-ego privides an easy way to integrate the `ego <https://github.com/benbjohnson/ego>`_ template engine into the `cidre <https://github.com/yuin/cidre/>`_ webframework.

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

.. code-block:: bash
   
   go get github.com/yuin/cidre-ego

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

Create ego templates and run the `ego` command.

.. code-block::

    <%! func ShowItems(w io.Writer, items []string) error %>
    <%% import "strings" %%>
    <%% import "github.com/yuin/cidre-ego" %%>
        <ul>
          <% for _, item := range items { %>
            <li><%= item %></li>
          <% } %>
        </ul>
    <% ego.EgoLayout(w, MyLayout) %>

.. code-block::

    <%! func MyLayout(w io.Writer, contents string) error %>
        <html><body>
        <%== contents %>
        </body></html>

.. code-block:: bash
    
    ego templates

Set EgoRenderer for a cidre app

.. code-block:: go

    app := cidre.NewApp(appConfig)
    app.Renderer = ego.NewEgoRenderer()
    items := app.MountPoint("/items/")
    items.Get("show_item", ".*", func(w http.ResponseWriter, r *http.Request) {
        app.Renderer.Html(w, ShowItems, []string{"a", "b", "c"})
    })

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EgoLayout

func EgoLayout(w io.Writer, args ...interface{})

Types

type EgoRenderer

type EgoRenderer struct {
	*cidre.BaseRenderer
}

func NewEgoRenderer

func NewEgoRenderer() *EgoRenderer

func (*EgoRenderer) Compile

func (r *EgoRenderer) Compile()

func (*EgoRenderer) Html

func (r *EgoRenderer) Html(w http.ResponseWriter, args ...interface{})

func (*EgoRenderer) RenderTemplateFile

func (r *EgoRenderer) RenderTemplateFile(w io.Writer, name string, value interface{})

Jump to

Keyboard shortcuts

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