1- var template = require ( 'lodash.template' ) ;
21var decls = require ( './decls.json' ) ;
32
3+ function template ( string , data ) {
4+ return string . replace ( / \$ \{ ( [ \w \- \. ] * ) \} / g, function ( _str , key ) {
5+ var v = data [ key ] ;
6+ return typeof v !== 'undefined' && v !== null ?v :'' ;
7+ } ) ;
8+ }
9+
410/*
511 Rules legend:
612 - combined - if rule is combined it will be rendered with template
@@ -23,8 +29,7 @@ function _compileDecls(inputDecls) {
2329var templateVars = _getRulesMap ( inputDecls ) ;
2430return inputDecls . map ( function ( decl ) {
2531if ( decl . combined && decl . initial ) {
26- var t = template ( decl . initial . replace ( / \- / g, '' ) ) ;
27- decl . initial = t ( templateVars ) ;
32+ decl . initial = template ( decl . initial . replace ( / \- / g, '' ) , templateVars ) ;
2833}
2934return decl ;
3035} ) ;
@@ -33,8 +38,8 @@ function _compileDecls(inputDecls) {
3338function _getRequirements ( inputDecls ) {
3439return inputDecls . reduce ( function ( map , decl ) {
3540if ( ! decl . contains ) return map ;
36- return decl . contains . reduce ( function ( mapInner , dependensy ) {
37- mapInner [ dependensy ] = decl ;
41+ return decl . contains . reduce ( function ( mapInner , dependency ) {
42+ mapInner [ dependency ] = decl ;
3843return mapInner ;
3944} , map ) ;
4045} , { } ) ;
@@ -46,11 +51,11 @@ function _expandContainments(inputDecls) {
4651. filter ( function ( decl ) {
4752return ! decl . contains ;
4853} ) . map ( function ( decl ) {
49- var dependensy = requiredMap [ decl . prop ] ;
50- if ( dependensy ) {
51- decl . requiredBy = dependensy . prop ;
52- decl . basic = decl . basic || dependensy . basic ;
53- decl . inherited = decl . inherited || dependensy . inherited ;
54+ var dependency = requiredMap [ decl . prop ] ;
55+ if ( dependency ) {
56+ decl . requiredBy = dependency . prop ;
57+ decl . basic = decl . basic || dependency . basic ;
58+ decl . inherited = decl . inherited || dependency . inherited ;
5459}
5560return decl ;
5661} ) ;