kangaroux / hamplify Goto Github PK
View Code? Open in Web Editor NEWHAML-ish template compiler written in Python
License: MIT License
HAML-ish template compiler written in Python
License: MIT License
:plain
will simply be taken as they are verbatim.
:javascript
and :css
will have an appropriate script/style tag wrapped around their contents.
When using Jinja2 or Django templates, the = var
syntax will compile to {{var}}
.
Example:
= user.username
%p= user.email
Gets compiled to:
{{user.username}}
<p>{{user.email}}</p>
When using this on the same line as a tag, there must not be any whitespace between the end of the tag and the =
. If there is, it will be interpreted as plain text.
The existing JS/CSS filters are :javascript
and :css
. An alternative syntax would be :js
and :stylesheet
, respectively.
#id can only come at the end of tag definitions currently. Sometimes tags have a long lists of classes and it would be better to have the ID at the start so it doesn't get lost.
The ID should NOT be able to appear in the middle of a list of classes. The ID should either either be at the beginning or the end.
The parser currently outputs a minimized version by not including whitespace. This will require that CRLF be properly carried over (#2)
Regular comments are not parsed which is correct, however since conditional IE comments aren't really comments, they should be parsed.
In general, if it's going to be rendered for use on the page, then the contents should be parsed.
http://haml.info/docs/yardoc/file.REFERENCE.html#conditional-comments-
Because the comment syntax in hamplify
is swapped the syntax will be -#[condition]
Usage:
-#[if lt IE 9]
%script(src="script.js")
Compiles to:
<!--[if lt IE 9]><script src="script.js"></script><![endif]-->
CRLF in --> CRLF out
LF in --> LF out
The compiler currently has error handling where it will raise a ParseError
if it encounters some bad syntax and doesn't know how to proceed. However, there are times where it would be more appropriate to notify the user about something but still proceed with compilation.
For example, if the user writes a conditional comment but puts some text after the comment:
-#[if IE] like this
We can parse that line just fine, but the text is ignored so it serves no purpose. It would be nice to notify the user that it should be removed.
If the template has single quotes for the attribute, then when converted it should still use single quotes. This causes issues when there are quotes inside attributes for template tags.
Template:
%img(src='{% static "some_url" %}')
Converted:
<img src="{% static "some_url" %}" />
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.