Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Another stab at #88 #99

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nunavut/jinja/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ def __init__(self,
keep_trailing_newline=True,
lstrip_blocks=lstrip_blocks,
trim_blocks=trim_blocks,
auto_reload=False)
auto_reload=False,
cache_size=0)

self._add_language_support()

Expand Down
2 changes: 1 addition & 1 deletion src/nunavut/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# This software is distributed under the terms of the MIT License.
#

__version__ = "0.1.12"
__version__ = "0.1.13"

__license__ = 'MIT'
17 changes: 17 additions & 0 deletions test/gentest_lang/templates/implicit/py/StructureType.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@

{% include "id.j2" %}

{# https://github.com/UAVCAN/nunavut/issues/88#issuecomment-546927646 #}
{% macro generate_unique_items() -%}
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
{%- endmacro %}
many_unique_names = [
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
'{{ 'f'|to_template_unique_name }}',
{{ generate_unique_items() }}
{{ generate_unique_items() }}
]

lang_py = {
'unique_name_0': '{{ "NAME" | to_template_unique_name }}',
'unique_name_1': '{{ "NAME" | to_template_unique_name }}',
'unique_name_2': '{{ "name" | to_template_unique_name }}',
'id_0': '{{ "identifier zero" | id }}',
'many_unique_names': many_unique_names,
}


Expand Down
5 changes: 5 additions & 0 deletions test/gentest_lang/test_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ def ptest_lang_py(gen_paths, implicit): # type: ignore
assert "_NAME1_" == lang_py_output["unique_name_1"]
assert "_name0_" == lang_py_output["unique_name_2"]
assert "identifier_zero" == lang_py_output["id_0"]

many_unique_names = lang_py_output.get("many_unique_names")
if many_unique_names is not None:
assert [('_f%d_' % x) for x in range(12)] == many_unique_names

return generated_values

# +---------------------------------------------------------------------------+
Expand Down