-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from google/crlf
Fix CRLF handling on Windows & lstrip_blocks + trim_blocks behaviour (testing against jinja2)
- Loading branch information
Showing
7 changed files
with
212 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Use of this source code is governed by an MIT-style | ||
# license that can be found in the LICENSE file or at | ||
# https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
import sys | ||
import json | ||
from jinja2 import Environment | ||
import jinja2.ext | ||
from pathlib import Path | ||
|
||
input_file, output_file = sys.argv[1:3] | ||
data = json.loads(Path(input_file).read_text()) | ||
# print(json.dumps(data, indent=2), file=sys.stderr) | ||
|
||
env = Environment(**data['options'], extensions=[jinja2.ext.loopcontrols]) | ||
tmpl = env.from_string(data['template']) | ||
output = tmpl.render(data['bindings']) | ||
Path(output_file).write_text(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.