danlarkin / clabango Goto Github PK
View Code? Open in Web Editor NEWit's a templating language for clojure I guess?
License: BSD 3-Clause "New" or "Revised" License
it's a templating language for clojure I guess?
License: BSD 3-Clause "New" or "Revised" License
added [clabango "0.5"]
to my project.clj
did lein deps
, no problems
did lein repl
entered:
(ns example.core (:require [clabango.filters :refer [deftemplatefilter]] [clabango.parser :refer [render]]))
got:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: context-lookup in this context, compiling:(clabango/tags.clj:67)
same error in any namespace:
(require '[clabango.parser :refer [render]])
When I mentioned this on #clojure, @bitemyapp suggested I file an issue, although I don't see this as a real bug.
When doing silly things with includes and extends, I get a 500 server error after a long loading period (and a huge stacktrace.)
Easiest steps to reproduce:
$ lein new luminus foo cd foo && vi src/foo/views/templates/about.html
insert into ~line 3 (after extends)
{% include "foo/views/templates/about.html" %}
then
lein ring server-headless
and surf to localhost:3000/about
This also works the other way round iirc, if you extend something that's including the file you work on - maybe it would make sense to add an arbitrary recursion limit of ~10 levels deep.
I don't know if this was the case before, but parse-filters is really slow.
The best way I can think to optimize this is to move as much of the template parsing into the pre-context-aware section and turn the filters into memoizable call-sites for injecting the data after the fact.
This would probably require writing a chunk of the parser into something that does as little as possible at the context-aware stage.
It also seems like a lot of time is being spent in the lazy-seq operations.
Do you know anything about this @danlarkin?
Currently if the application is deployed on an application server, such as tomcat, with a context other than root then static resources will not be served correctly.
Would it be possible to add something for handling the servlet context when serving static resources. For example, Hiccup provides wrap-base-url middleware and uses it when parsing the templates.
The workaround right now would be to do something like this in the template
<link href="{{context}}/css/screen.css" rel="stylesheet" type="text/css"></link>
and then pass the context in to the template
(render-file "mytemplate.html" {:context (:context *request*)})
it gets kinda tedious to do :)
Thank you for writing a template engine similar to Django's and Jinja. I've been trying to incorporate it into a prototype application, and discovered an interesting behavior. If I create a new template tag that is identical to upper
, but with a different name, I end up with the result being rendered as a map.
The function is this:
(deftemplatefilter "my-upper" [node body arg]
(when body
{:body (.toUpperCase body)}))
If I use this, I end up with the value being rendered as a map with a :body
entry: {:body "JOHN"}
. If I change it to not wrap in a map, then it renders correctly. But that seems to go against the precedent set in clabango. Is there something broken here?
Would it be possible to add else in addition to if as in Django?
{% if athlete_list %}
Number of athletes: {{ athlete_list|length }}
{% else %}
No athletes.
{% endif %}
I've tried everything I could in Luminus but no way "include" will work. Any other magic required that didn't get mentioned perhaps? Am I missing something?
update: It still doesn't work like expected, but now I just rendered it (a menu to plug in) as a key of the object sent to the template and it includes the menu I wanted.
Anyhow it seems to be a lack of understanding / Luminus perhaps on my part. Either their guide is missing information or it's broken.
extends inline
This tag is also used in template inheritance -- It defines the current template as inheriting from another.
Note use of the word also. For what other purposes is it used then?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.