EzDevInfo.com

jaml

JavaScript Haml Jaml: beautiful HTML generation for JavaScript | Ed Spencer generating html with javascript has always been ugly. hella ugly. it usually involves writing streams of hard-to-maintain code which just concatenates a bunch of strings together and spits them out in an ugly mess. wouldn't it be awesome if we could do something pretty like this: and have it output something beautiful like this: with…

Javascript Template Engines that work with Chrome's Content Security Policy

The Chrome API's Manifest version 2 has removed the ability to do unsafe-eval. This means using the eval function or in general dynamically creating a function from text.

It seems like most if not all Javascript Templating Engines do this. I was using Jaml, but I tried several others like backbone.js (which really uses underscore.js's templating engine) with no luck.

This comment on the Chromium project seems to indicate that there are a great many libraries that suffer from this.

I think Angular.js has a CSP-safe mode, but Angular.js is really too big for what we need. We just need a fairly basic templating engine and don't need models or controllers and such. Does anyone know about any CSP-compatbility templating engines out there?


Source: (StackOverflow)

Instance Eval in Javascript around browsers

From Coffeekup and JAML's source, (while working on question), we can see a way to hack ruby's instance eval into Javascript (JAML author explains more). It involves decompiling the function, and evaluating it around a with block.

The question is: is this supported all around browsers/js runtimes? I know it works on firefox, opera and chrome, but toString on function is not consistent among platforms, hence the question.


Source: (StackOverflow)

Advertisements

Saltstack load pillar in a for loop

I am developing a automatic proftd installation whit Salt, i wont to get the ftp users from a template but I cant get work the pillar, i initialized the pillar whit the users data and call it into a for loop, but you don't get the pillar user data in the loop.

When i make salt-call pillar.get ftpusers in the minion, the response is:

local:

This is my pillar ftpusers.sls:

ftp-server.ftpusers:
  user:
    - user: user
    - passhash: j2k3hk134123l1234ljh!"ยท$ser
    - uuid: 1001
    - guid: 1001
    - home: /srv/ftp/user
    - shel: /bin/false

And this is the for loop:

{% for users in pillar.get('ftpusers', {}).items() %}

  /srv/herma-ftp/.ftpusers:
    file.managed:
      - user: root
      - group: root
      - mode: 444
      - contents:'{{ user }}:{{ args['passhash'] }}:{{args['uuid'] }}:{{ args['guid'] }}::{{ args['home'] }}:{{ args['shel'] }}'
      - require:
        - file: /srv/herma-ftp

  /srv/herma-ftp/{{user}}:
    file.directory:
      - user: nobody
      - group: nobody
      - dir_mode: 775
      - makedirs: True
      - require:
        - file: /srv/herma-ftp
      - watch:
        - file: /srv/herma-ftp
    module.run:
      - name: file.set_selinux_context
      - path: {{ args['home']}}
      - type: public_content_t
      - unless:
        - stat -c %C {{ args['home'] }} |grep -q public_content_t

{% endfor %}

When I make in the minion

salt-call -l debug state.sls herma-ftp-server saltenv=My-enviroment test=True

Don't expect this for because don't can get the pillar data.


Source: (StackOverflow)

Coffescript, Jaml like template engine

I'm just experimenting the various javascript template engines (client-side) for my backbone views...

And i found this old project: https://github.com/edspencer/jaml

It seems good to me, because i dont have to use of long string blocks like other template engines (like handlebars or underscore..)

The problem is that Jaml is really outdated, and it seems there's no successor to it...

Someone has new resources to share about?

As always, i'm sorry for my bad english :S


Source: (StackOverflow)

Javascript bind "this" to event

Below is an error I am getting from binding "this" to a click event in javascript. The format of the js is Jaml/Mooml and may be unfamiliar to some but I assure you the syntax is proper. I have been binding "this" to many events in the same way and this is the first time I have seen this error so I am hoping some mootools, jaml or javascript expert will be able to derive a solution from the error and code below.

Uncaught TypeError: Object [object Object] has no method 'get'
Mooml.engine.tags.div.Mooml.engine.tags.div.events.click:relay(a)
bubbleUpmootools-core-1.4.1.js:3948
delegation.addEvent.delegatormootools-core-1.4.1.js:4078
defn

here is the Jaml...

    'main': new Mooml.Template(null, function(data) {
        div({'class': 'lists container'},
            div({
                'class': 'sources',
                'events': {
                    'click:relay(a)': function(event) {
                        event.preventDefault();

                        new Resource({
                            'url': this.get('href'),
                            'method': 'FRIENDS',
                            'query' : {
                                'source': this.dataset.source
                            },

                            'onSuccess': function(response) {
                                console.log(response);
                                //this.renderTemplate('friends', response.mv, this);

                            }.bind(this),

                            'onFailure': this.onFailure

                        }).send();

                    }.bind(this)
                }

Source: (StackOverflow)