HAML + AngularJS: create your own prefix "ng", for example, "data",

HAML understands the basic hash for the "data" keyword, so:

%div{ data: { id: "5", name: "carsten" } }

equivalently

%div{ 'data-id' => "5", 'data-name' => "carsten" }

IMHO the previous syntax is much more readable.

AngularJS uses many ng-something attributes. Is it possible to configure HAML to:

%html{ 'ng-app' => "myApp", 'ng-controller' => "myCtrl" }

can be written as

%html{ ng: { app: "myApp", controller: "myCtrl" } }

+4
source share
1 answer

You do not need to configure anything, since the current version works already:

%html{ ng: { app: "myApp", controller: "myCtrl" } }

gives:

<html ng-app='myApp' ng-controller='myCtrl'></html>

Documents need updating, but the current behavior is any attribute with a value that is a hash, in this way, and not just that data.

+5
source

Source: https://habr.com/ru/post/1524183/


All Articles