Giter VIP home page Giter VIP logo

zenekindarl's Introduction

Build Status Coverage Status

Zenekindarl

Expected to be a fast, flexible, extensible, low memory usage, async, concurrent template engine.

Usage

Like this

(render "Hello {{var name}}!!"
        :name "κeen")
(let ((renderer (compile-template-string :stream "Hello {{var name}}!!")))
  (funcall renderer *standard-output* :name "κeen"))

.

For more information, see docstring

Instant Benchmark

Zenekindarl perform x16 as fast as a template engine in Python in the following instant benchmark.

Benchmark

Template engines Time[sec]
Zenekindarl, SBCL 1.1.8 1.365
Jinja2, Python 2.7.5 24.07

The benchmark code for Zenekindarl:

> (time
   (with-open-file (out #P"~/Desktop/out" :direction :output :if-exists :supersede)
     (let ((fun (zenekindarl:compile-template-string :stream "Hello {{var name}}!!")))
       (loop repeat 1000000
          do (funcall fun out :name "κeen")))))
Evaluation took:
1.625 seconds of real time
1.364707 seconds of total run time (1.302198 user, 0.062509 system)
[ Run times consist of 0.042 seconds GC time, and 1.323 seconds non-GC time. ]
84.00% CPU
1 form interpreted
3 lambdas converted
3,265,218,807 processor cycles
528,706,464 bytes consed

The benchmark code for a template engine in Python:

$ cat te.py
from jinja2 import Template

template = Template( u'Hello {{ name }}!!' )

f = open( 'out', 'w' )
for i in range( 1000000 ):
  f.write( template.render( name=u'κeen' ).encode( 'utf-8' ) )

$ time python te.py
real    0m25.612s
user    0m24.069s
sys	    0m0.190s

Syntax

Variable

variables will be HTML escaped

{{var foo}}

Repeat

{{repeat 10}}hello{{endrepeat}}
{{repeat n as i}}<li>{{var i}}th item</li>{{endrepeat}}

Loop

<ol>
  {{loop items as item}}
  <li>{{var item}}</li>
  {{endloop}}
</ol>

If

{{if new-p}}New{{else}}Old{{endif}}

Insert

See code below
<code><pre>
{{insert "snippet.lisp"}}
</pre></code>

Include

<nav>
{{incude "sidebar.tmpl"}}
</nav>

Author

  • κeen

Copyright

Copyright (c) 2014 κeen

zenekindarl's People

Contributors

cxxxr avatar fukamachi avatar keens avatar rudolph-miller avatar takagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zenekindarl's Issues

SBCL complains about quoted types

when compiling att.lisp with current SBCL (2.2.7.128), I see a bunch of errors of the following form:

; in: DEFCLASS ZENEKINDARL.ATT:ATT-VARIABLE
;     '(OR :STRING :ANYTHING)
; 
; caught WARNING:
;   Undefined type '(OR :STRING :ANYTHING). The name starts with QUOTE: probably
;   use of a quoted type name in a context where the name is not evaluated.

; in: DEFCLASS ZENEKINDARL.ATT:ATT-GENSYM
;     '(OR NULL STRING)
; 
; caught WARNING:
;   Undefined type '(OR NULL STRING). The name starts with QUOTE: probably use of a
;   quoted type name in a context where the name is not evaluated.

; in: DEFCLASS ZENEKINDARL.ATT:ATT-LEAF
;     '(OR NULL T)
; 
; caught WARNING:
;   Undefined type '(OR NULL T). The name starts with QUOTE: probably use of a
;   quoted type name in a context where the name is not evaluated.

; in: DEFCLASS ZENEKINDARL.ATT:ATT-PROGN
;     'LIST
; 
; caught WARNING:
;   Undefined type 'LIST. The name starts with QUOTE: probably use of a quoted type
;   name in a context where the name is not evaluated.

Improper ASDF usage

1- You MUST NOT do a clear-system in your perform method in zenekindarl-test

2- The :after in said method, as well as the in-package and defpackage forms, are bad memories of ASDF 1, not needed and not recommended since ASDF 3 (2013).

3- The funcall... can be simply (symbol-call :prove :run-test-system)

4- It is better form to put :defsystem-depends-on before the forms that depend on it (in this case the :component form.

5- You can slurp the contents of a file with uiop:read-file-string; not that I recommend you do it. I believe it is poor form and doesn't help in this case.

MPC is going to be deprecated in favor of MaxPC

Hi @KeenS,

I want to deprecate MPC in favor of MaxPC (not yet in Quicklisp). From my point of view MaxPC is a clear improvement in every aspect (ease of use, expressiveness, performance) over MPC, but you might disagree (it does not support ambiguous languages, and is not really monadic). This is just letting you know early that I no longer support MPC (it will remain in Quicklisp for as long as possible though, which might be forever since it does not rely on any implementation specific API).

Are you interested in transitioning to MaxPC? If so let me know any issues you have with it.

How can one emit a single curly-brace before/after a template variable?

I'd like to do something like {{{var foo}}} and have the output be {whatever foo contains}. Is this possible? Can I escape a single curly brace? Is there a literal syntax ala {{ "{" }} I could use?

My workaround is to pass in lbrace and rbrace args and do e.g. {{var lbrace}} but this seems rather hacky.

I want to use auto-escape in variable.

<html>
<body>
{{ var body }}
</body>
</html>

としてbodyにhtmlを埋め込みたいんですが
このままだとエスケープされるので
att-leafクラスを継承するatt-variableクラスでスロットauto-escapeをnilにする必要があるんですが
外部からそれをする方法が見つかりません

テンプレートファイルで{{ var body auto-escape:nil }}と指定出来ると良いんですが
それをするためにはlexerとparserに手を入れないと駄目ですね
parserに使われているmpcもmaxpcに書き換える必要もあるように見えるんですが
色々とコンフリクトしそうです

どうすればいいですか

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.