1- // ------------------------------------
2- // #POSTHTML - EXPS
3- // ------------------------------------
4-
5- 'use strict'
6-
7- let get = require ( './lib/get' )
8- let locals = require ( './lib/local' )
9-
10- let attrs = require ( './lib/attrs' )
11- let exps = require ( './lib/exps' )
12- let pipe = require ( './lib/pipe' )
13- let each = require ( './lib/each' )
14- let partial = require ( './lib/part' )
15- // let condition = require('./lib/if')
16-
17- exports = module . exports = function ( options ) {
18- options = options || { }
1+ const attrs = require ( './lib/attrs' )
2+ const exps = require ( './lib/exps' )
3+ const pipe = require ( './lib/pipe' )
4+ const each = require ( './lib/each' )
5+ const partial = require ( './lib/part' )
196
7+ exports = module . exports = function ( options = { } ) {
208 if ( typeof options . locals === 'string' ) {
219 options . locals = require ( options . locals )
2210 }
2311
24- let style = options . style || '{'
25- let local = options . locals || { }
12+ const style = options . style || '{'
13+ const local = options . locals || { }
2614
2715 return function PostHTMLExps ( tree ) {
2816 tree . walk ( ( node ) => {
29- let attributes = node . attrs || { }
30- let content = node . content || [ ]
17+ const attributes = node . attrs || { }
18+ const content = node . content || [ ]
3119
3220 let exp
3321
3422 Object . keys ( attributes ) . forEach ( attr => {
3523 exp = attributes [ attr ]
3624
3725 if ( exp . includes ( style ) ) {
38-
3926 if ( ! exp . includes ( '.' ) ) {
4027 node . attrs [ attr ] = attrs ( local , style , exp )
4128 }
@@ -44,18 +31,14 @@ exports = module.exports = function (options) {
4431 node . attrs [ attr ] = attrs ( local , style , exp )
4532 }
4633 }
47-
4834 } )
4935
5036 if ( content . length === 1 ) {
5137 if ( typeof content [ 0 ] === 'string' ) {
52-
5338 exp = content [ 0 ] . trim ( )
5439
5540 if ( content [ 0 ] . includes ( exp ) ) {
56-
5741 if ( ! exp . includes ( '.' ) ) {
58-
5942 if ( exp . includes ( `${ style } ` ) ||
6043 exp . includes ( ` ${ style } ` ) &&
6144 ! exp . includes ( `>` ) &&
@@ -84,13 +67,11 @@ exports = module.exports = function (options) {
8467 }
8568
8669 if ( exp . includes ( '.' ) ) {
87-
8870 if ( exp . includes ( `${ style } ` ) &&
8971 ! exp . includes ( `|` ) &&
9072 ! exp . includes ( `>` ) &&
9173 ! exp . includes ( `...` )
9274 ) {
93-
9475 node . content = exps ( local , style , exp , node . content [ 0 ] )
9576 }
9677
0 commit comments