sintro / slm

Slim, Jade like template engine for node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slm-angular2

With Angular 2 support

Slm is a template language for js. Port of Slim but slimmer :)

What changed?

There are some changes in parser regexps and functions, which make possible of using Angular 2 template constructions in slim templates:

  • (click)="something"
  • [style]="something"
  • [(ngModel)]="something"
  • #localvar="something"
  • #localvar
  • *ngFor="#item of items" (etc) were working fine already
  • bind- (etc) were working fine already

Conflicts and limitations

These changes in parser can be the reason of strange behavior in some rare cases, which can be avoided by using different notations, for example:

div #event

This will be interpreted as div element with #event attribute. In original Slm #event would be the content of tag. So, if you need to start the content with hash symbol, you need to do something like:

div 
  | #event

Some problems are possible if you wrap attributes with [] or (), and the first attribute is one of Angular`s attributes with brackets. If you faced with them, try to add whitespace after wrapper opening brackets, or just reorder the attributes so the first one will be some simple html one.

There are also no validation of the brackets order for Angular2 attributes: so you can type [(ngModel]) and it will be rendered the same way without any warning. It is huge pain for me to make regexps which care of this without conditional groups (in JavaScript). Anyway, I don`t think that this is problem.

There is also no possibility of making code values for hash-attributes (like #localvar=alert('Hello world')). I think it is excessive functionality.

Original Slm links

How to start?

This npm module is not published in npm, and used in some tools (https://github.com/sintro/slm-brunch) directrly by this git repo. Hope, one day the angular2 support will be the part of original Slm and there will be no reason to produce clone-modules in npm.

License

Slm-angular2 is released under the MIT license.

Special Thanks

About

Slim, Jade like template engine for node

License:MIT License


Languages

Language:JavaScript 99.5%Language:HTML 0.5%