Beispiel #1
0
 def get_macro(self):
     name = self.get_name()
     template = self.get_template()
     # make the module. previously we set both vars and local, but that's
     # redundant: They both end up in the same place
     module = template.make_module(vars=self.context, shared=False)
     macro = module.__dict__[get_dbt_macro_name(name)]
     module.__dict__.update(self.context)
     return macro
Beispiel #2
0
    def parse_macro(self):
        node = jinja2.nodes.Macro(lineno=next(self.stream).lineno)

        # modified to fuzz macros defined in the same file. this way
        # dbt can understand the stack of macros being called.
        #  - @cmcarthur
        node.name = get_dbt_macro_name(
            self.parse_assign_target(name_only=True).name)

        self.parse_signature(node)
        node.body = self.parse_statements(('name:endmacro', ),
                                          drop_needle=True)
        return node