question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add name and filename to Environment.from_string

See original GitHub issue

What do you think about add name and filename parameters in Environment.from_string method ? https://github.com/pallets/jinja/blob/master/jinja2/environment.py#L849

Something like that:

    def from_string(self, source, name=None, filename=None, globals=None, template_class=None):
        """Load a template from a string.  This parses the source given and
        returns a :class:`Template` object.
        """
        globals = self.make_globals(globals)
        cls = template_class or self.template_class
        return cls.from_code(self, self.compile(source, name=name, filename=filename), globals, None)

Best regards, Stéphane

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mitsuhikocommented, Aug 29, 2017

Correct, that will work.

0reactions
guilhem-commented, Nov 7, 2019

Right. Even if providing two times the same information to a component may sound as unoptimal from a caller point of view, I can understand other reasons exist not to do it from a callee perspective…

Finally using Ansible, it appeared to be as simple as the following code to transfer the file name information into the template…

template: src: ‘{{ src_dir }}’ dest: ‘{{ dst_dir }}’ vars: file_path: “{{item.path}}” with_filetree: templates/xyz

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import file using string as name - python - Stack Overflow
Add the path where module resides to sys.path. Import the module using __import__ function which accepts a string variable as module name.
Read more >
How to retrieve environment variable from string name in KSH
and 'envVar' is the one of my environment variable's name containing a path (of a folder by instance). So I'd like to do...
Read more >
GNU make - Functions for Transforming Text
Filename Functions: Functions for manipulating file names. Foreach Function: Repeat some text with controlled variation. Origin Function: Find where a variable ...
Read more >
setx - Microsoft Learn
Creates or modifies environment variables in the user or system environment, ... setx [/s <computer> [/u [<domain>\]<user name> [/p ...
Read more >
Python Generated Code | Protocol Buffers - Google Developers
The Python code generated by the protocol buffer compiler is completely unaffected by the package name defined in the .proto file. Instead, Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found