File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,23 +20,17 @@ module.exports = (options = {}) => {
2020 let content ;
2121 let subtree ;
2222 let source ;
23- let locals ;
24-
25- const localsString = node . attrs . locals || ( node . content ? node . content . join ( ) . replace ( / \n / g, '' ) : '' ) ;
26- const tryToParseLocals = localsString . trim ( ) && localsString . trim ( ) . startsWith ( '{' ) ;
27-
28- if ( tryToParseLocals ) {
29- try {
30- locals = JSON . parse ( localsString ) ;
31- } catch {
32- locals = false ;
33- }
34- }
23+ let locals = false ;
3524
3625 if ( src ) {
3726 src = path . resolve ( options . root , src ) ;
3827 source = fs . readFileSync ( src , options . encoding ) ;
3928
29+ try {
30+ const localsRaw = node . attrs . locals || ( node . content ? node . content . join ( ) . replace ( / \n / g, '' ) : false ) ;
31+ locals = JSON . parse ( localsRaw ) ;
32+ } catch { }
33+
4034 if ( locals ) {
4135 const result = posthtml ( )
4236 . use ( expressions ( { locals} ) )
You can’t perform that action at this time.
0 commit comments