Skip to content

Commit 89871d2

Browse files
Thomas SmithThomas Smith
authored andcommitted
2 parents 25eef05 + 396b017 commit 89871d2

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/macros.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
from yamlmacros.lib.extend import apply
22
from yamlmacros.lib.syntax import rule as _rule
3+
from yamlmacros.lib.include import include_resource
34

45
from yamlmacros import process_macros
56

67
import sublime
78
from os import path
89

9-
def include_resource(resource):
10-
file_contents = sublime.load_resource(resource)
11-
return process_macros(
12-
file_contents,
13-
arguments={ "file_path": resource },
14-
)
10+
11+
__all__ = ['apply', 'include_resource', 'get_extensions']
12+
13+
14+
def merge(*args):
15+
ret = {}
16+
for arg in args:
17+
ret.update(arg)
18+
return ret
1519

1620
def has_value(val):
1721
return val is not None and val is not False
1822

1923
def get_extensions(node, eval, arguments):
2024
return [
21-
include_resource(file_path)
25+
process_macros(
26+
sublime.load_resource(file_path),
27+
arguments=merge(arguments, { "file_path": file_path }),
28+
)
2229
for file_path in sublime.find_resources('*.yaml')
2330
if path.dirname(file_path).endswith('Packages/JSCustom/extensions')
2431
and has_value(arguments.get(path.splitext(path.basename(file_path))[0], None))

0 commit comments

Comments
 (0)