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

_copy_without_render does not work properly #1817

Open
rdvansloten opened this issue Feb 9, 2023 · 4 comments
Open

_copy_without_render does not work properly #1817

rdvansloten opened this issue Feb 9, 2023 · 4 comments

Comments

@rdvansloten
Copy link

  • Cookiecutter version: 2.1.1
  • Template project url: Private
  • Python version: 3.10.9
  • Operating System: MacOS

Description:

I have a Terraform Docs file inside my {{cookiecutter.module_name}} folder with this content;

formatter: markdown table

sort:
  enabled: true
  by: required

output:
  file: README.md
  mode: inject
  template: |-
    [//]: # (BEGIN_TF_DOCS)
    {{ .Content }}
    
    [//]: # (END_TF_DOCS)

And cookiecutter does not handle the {{ .Content }} line.

What I've run:

"_copy_without_render": [
    "{{cookiecutter.module_name}}/.terraform-docs.yml"
]

"_copy_without_render": [
    "*/.terraform-docs.yml"
]

"_copy_without_render": [
    ".terraform-docs.yml"
]

Thinking maybe the leading period matters, I renamed the file, also did not work:
"_copy_without_render": [
    "terraform-docs.yml"
]

I have also tried wrapping it, to no avail: ${{ "{{" }} .Content {{ "}}" }}

When using _copy_without_render:

  File "/opt/homebrew/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "terraform-docs.yml", line 12, in template
jinja2.exceptions.TemplateSyntaxError: unexpected '.'
  File "terraform-docs.yml", line 12
    {{ .Content }}

When wrapping in multiple brackets:

Unable to create file 'pipelines/terraform-docs.yml'
Error message: 'parameters' is undefined
Context: {
    "cookiecutter": {
        "_copy_without_render": [
            "{{cookiecutter.module_name}}/.terraform-docs.yml"
        ],
@matt-horwood-mayden
Copy link

  • Cookiecutter version: 2.3.1
  • Template project url: Private
  • Python version: 3.10.13
  • Operating System: MacOS

This is still a bug, how do we get it fixed please

@padraic-padraic
Copy link
Contributor

I've been using _copy_without_render myself; the paths you specify are actually relative to the template directory, so you don't need the {{cookiecutter.module_name}}/ there!

@matt-horwood-mayden
Copy link

I tryied with and without, this is the config I have that doesnt work

    "_copy_without_render": [
      "*/create.yml",
      "*/destroy.yml"
    ]

@maurczz
Copy link

maurczz commented Dec 22, 2023

I was having the same issue and had to debug the source code to understand what was happening. This is the line that checks if the path you have in _copy_without_render matches the path that cookiecutter is parsing from your template.

I'd advise you to just add a breakpoint() in there to check why your paths were not properly excluded from the rendering process. I was going a bit insane but in my case it was totally my fault due to a malformed path. Worth noting that I'm not saying it's your fault either; just trying to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants