slm-lang / slm

Slim, Jade like template engine for node
MIT License
197 stars 16 forks source link

Dependancies #22

Closed ComLock closed 8 years ago

ComLock commented 8 years ago

Your package.json states no dependancies, but I can find several:

grep -r 'require(' .|grep -v "'\."
./slm.js:var FS = require('fs');
./vm_node.js:var FS = require('fs');
./vm_node.js:var NodeVM = require('vm');
./vm_node.js:var Path = require('path');

I'm trying to use slm with this CMS https://enonic.com/

Which is using thymeleaf by default. Slm is a lot slimmer :) me want.

The runtime is java, but the controllers are written in javascript.

All I really need is to slm.compile a slm file, passing in a model.object (a basic hash), and get back some html. Do I need Node VM, etc for that?

Could slm be shipped as a webjar? http://www.webjars.org/

ComLock commented 8 years ago

Enonic has its own require: http://xp.readthedocs.org/en/stable/developer/ssjs/global-objects.html?highlight=require#require

So node_modules is not really accessable.

I guess I could try making a webpack with slm, fs, vm and path.

ComLock commented 8 years ago

slm_browser.js got me a bit further.

TypeError: str.split is not a function https://github.com/slm-lang/slm/blob/master/lib/parser.js#L122

ComLock commented 8 years ago

My bad, takes a string. Some documentation would be lovely.

ComLock commented 8 years ago
javax.servlet.ServletException: com.enonic.xp.resource.ResourceNotFoundException: Resource [website:/site/node_modules/slm/lib/vm_browser.js#11:9<eval>] was not found
ComLock commented 8 years ago

If I use render and set filename to be the slm file in options it works :)

Now I just have to figure out how to do a foreach, would be nice with a documentation example of that.

ComLock commented 8 years ago

This is the syntax I tried to copy: https://github.com/slm-lang/slm/blob/00296f724d6b78e54dae604807ae85d90492df87/test/core/code_structure.js#L232-L233

This is my code (which does not work)

- this.buttons.forEach(function(button))
    a.button href=button.url = button.label

And gives me this probably unrelated error. (There are typically just 1 or 2 buttons)

javax.servlet.ServletException: java.lang.IndexOutOfBoundsException: start index (43) must not be greater than size (18)
ComLock commented 8 years ago

Tried this syntax too: https://github.com/slm-lang/slm/blame/master/README.md#L116

Maybe it's because I'm trying to set an attribute, nope removing that did not help, hmmm.

ComLock commented 8 years ago

Turns out this.buttons was empty, and my

- if this.buttons.length

Was not good enough.