How to use the chevron.renderer function in chevron

To help you get started, we’ve selected a few chevron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tencentyun / tcfcli / tcfcli / cmds / local / generate_event / generate_event_action.py View on Github external
def action(self, ctx, *args, **params):
        action = ctx.info_name
        params_tmp = self.srv_info[action][self.PARAMS]

        params = self._param_encode(params,  params_tmp)

        pwd = os.path.dirname(os.path.abspath(__file__))
        filename = self.srv_info[action]["filename"] + ".js"
        path = os.path.join(pwd, "events", self.service, filename)

        with io.open(path, encoding="utf-8") as f:
            data = f.read().strip()

        data = renderer.render(data, params)
        click.secho(json.dumps(json.loads(data), indent=2))
github awslabs / aws-sam-cli / samcli / commands / local / lib / generated_sample_events / events.py View on Github external
tags = self.event_mapping[service_name][event_type]["tags"]
        values_to_sub = self.encode(tags, "encoding", values_to_sub)

        # construct the path to the Events json file
        this_folder = os.path.dirname(os.path.abspath(__file__))
        file_name = self.event_mapping[service_name][event_type]["filename"] + ".json"
        file_path = os.path.join(this_folder, "events", service_name, file_name)

        # open the file
        with open(file_path) as f:
            data = json.load(f)

        data = json.dumps(data, indent=2)

        # return the substituted file
        return renderer.render(data, values_to_sub)
github tencentyun / scfcli / tcfcli / cmds / local / generate_event / generate_event_action.py View on Github external
def action(self, ctx, *args, **params):
        action = ctx.info_name
        params_tmp = self.srv_info[action][self.PARAMS]

        params = self._param_encode(params, params_tmp)

        pwd = os.path.dirname(os.path.abspath(__file__))
        filename = self.srv_info[action]["filename"] + ".js"
        path = os.path.join(pwd, "events", self.service, filename)

        with io.open(path, encoding="utf-8") as f:
            data = f.read().strip()

        data = renderer.render(data, params)
        Operation(json.dumps(json.loads(data), indent=2)).echo()

chevron

Mustache templating language renderer

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis