Coder Social home page Coder Social logo

egon's People

Contributors

benbjohnson avatar bouk avatar mattn avatar nalanj avatar slinso avatar xe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

egon's Issues

Add more tags, sanitize existing

I would suggest adding a few tags from EJS:

<%= Outputs the value into the template (HTML escaped)
<%- Outputs the unescaped value into the template
<%# Comment tag, no execution, no output
%> Plain ending tag
-%> Trim-mode ('newline slurp') tag, trims following newline

The raw print block already exists as <%==, but I'd consider changing this to EJS syntax.

I'd also do something with <%% and %%>, changing the closing tag just to %>? With the addition of -%> (see above), we can get rid of some extra whitespaces because of <%% and <%! definitions.

Support includes on compile time

I'm splitting up a project into many files, like this:

./partials/head.ejs
./partials/header.ejs
./partials/foot.ejs
./partials/footer.ejs
./index.ejs
./content/setup.ejs
./content/login.ejs
./content/error.ejs

Using them with available functions is a bit of a hassle as I have to take care of a few horrible things to make this usable. For example, my index.ejs looks something like this:

<%%
import (
        "app/common"
        "app/web/templates/partials"
        "app/web/templates/content"
        "github.com/codegangsta/inject"
)
%%><%! injector inject.Injector, view common.View %><%

        injector.Invoke(partials.HeadTemplate)
        injector.Invoke(partials.HeaderTemplate)

        %><div class="container-fluid"><%

        switch {
                case view.Content == "error":
                        injector.Invoke(content.ErrorTemplate)
                        break
                case view.Content == "setup":
                        injector.Invoke(content.SetupTemplate)
                        break
                case view.Content == "login":
                        injector.Invoke(content.LoginTemplate)
                        break
        }

        %></div><%

        injector.Invoke(partials.FooterTemplate)
        injector.Invoke(partials.FootTemplate)
%>

The problems with this approach:

  1. I have to define extra imports
  2. I have to use injection in the template

One possible fix would be to add an option to compile everything into one golang file, so I could skip additional imports (solves 1/2 of the problem). The name generation for functions is good enough to prevent clashes.

I suggest to add an include statement, that would "copy-paste" the file contents on compile time into the main source file. From EJS:

Includes are relative to the template with the include call. For example if you have "./views/users.ejs" and "./views/user/show.ejs" you would use <%- include('user/show'); %>.

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.