Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1e8547e

Browse files
fix: clean up Jinja templates for better readability
1 parent ccb8f9e commit 1e8547e

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

‎src/gitingest/output_formatter.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,39 +183,32 @@ def _(self, node: FileSystemFile, query):
183183
{{ SEPARATOR }}
184184
{{ node.name }}
185185
{{ SEPARATOR }}
186-
187186
{{ node.content }}
188187
"""
189188
file_template = self.env.from_string(template)
190189
return file_template.render(SEPARATOR=SEPARATOR, node=node, query=query, formatter=self)
191190

192191
@format.register
193192
def _(self, node: FileSystemDirectory, query):
194-
template = """
195-
{% if node.depth == 0 %}
196-
{{ node.name }}:
193+
template = """{%- if node.depth == 0 %}{{ node.name }}:
197194
{{ node.tree }}
198195
199-
{% endif %}
200-
{% for child in node.children %}
196+
{% endif -%}
197+
{%- for child in node.children -%}
201198
{{ formatter.format(child, query) }}
202-
{% endfor %}
203-
"""
199+
{%- endfor -%}"""
204200
dir_template = self.env.from_string(template)
205201
return dir_template.render(node=node, query=query, formatter=self)
206202

207203
@format.register
208204
def _(self, node: GitRepository, query):
209-
template = """
210-
{% if node.depth == 0 %}
211-
🔗 Git Repository: {{ node.name }}
205+
template = """{%- if node.depth == 0 %}🔗 Git Repository: {{ node.name }}
212206
{{ node.tree }}
213207
214-
{% endif %}
215-
{% for child in node.children %}
208+
{% endif -%}
209+
{%- for child in node.children -%}
216210
{{ formatter.format(child, query) }}
217-
{% endfor %}
218-
"""
211+
{%- endfor -%}"""
219212
git_template = self.env.from_string(template)
220213
return git_template.render(node=node, query=query, formatter=self)
221214

@@ -232,18 +225,18 @@ def _(self, node: FileSystemSymlink, query):
232225
@format.register
233226
def _(self, context: Context, query):
234227
"""Format a Context by formatting all its sources."""
235-
template = """
236-
# Generated using https://gitingest.com/{{ context.query.user_name }}/{{ context.query.repo_name }}
228+
template = \
229+
"""# Generated using https://gitingest.com/{{ context.query.user_name }}/{{ context.query.repo_name }}
230+
237231
Sources used:
238-
{% for source in context.sources %}
232+
{%- for source in context.sources %}
239233
- {{ source.name }}: {{ source.__class__.__name__ }}
240234
{% endfor %}
241235
242-
{% for source in context.sources %}
236+
{%- for source in context.sources %}
243237
{{ formatter.format(source, context.query) }}
244-
{% endfor %}
245-
# End of generated content
246-
"""
238+
{%- endfor %}
239+
# End of generated content"""
247240
context_template = self.env.from_string(template)
248241
return context_template.render(context=context, formatter=self)
249242

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /