# Add tagged template literals

**URL:** <https://discuss.python.org/t/add-tagged-template-literals/17685>\
**Category:** Ideas\
**Created:** [July 26, 2022, 1:17am UTC](https://discuss.python.org/t/add-tagged-template-literals/17685 "2022-07-26T01:17:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![conao3](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/conao3/32/8255_2.png) [@conao3](https://discuss.python.org/u/conao3)\
**Post date:** [July 26, 2022, 1:17am UTC](https://discuss.python.org/t/add-tagged-template-literals/17685/1 "2022-07-26T01:17:19Z")

</div>

**Feature or enhancement**  
Thanks for such a great language and ecosystems! And I love Python’s `f-string`.  
I zapped some website, Javascript has _Tagged template literals_, and it is a powerful feature.

- [Template literals (Template strings) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates)
- [Tagged Template Literals - Wes Bos](https://wesbos.com/tagged-template-literals)

**Pitch**

It has similar functionality to f-string, but allows the value to be passed through a specific function before embedding, or to be reformatted for the entire resulting string.  
This functionality is also used in a javascript project called [lit](https://lit.dev/), which is achieved through tagged literals rather than jsx.

Have we ever talked about introducing tagged literals?  
I would really like to use this in Python, and I would like to see this functionality used in Python.

**Previous discussion**

> <https://github.com/python/cpython/issues/94720>
>
> \*\*Feature or enhancement\*\*
> Thanks for such a great language and ecosystems! And… I love Python's \`f-string\`.
> I zapped some website, Javascript has \*Tagged template literals\*, and it is a powerful feature.
> \- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template\_literals#tagged\_templates
> \- https://wesbos.com/tagged-template-literals
> 
> 
> \*\*Pitch\*\*
> 
> It has similar functionality to f-string, but allows the value to be passed through a specific function before embedding, or to be reformatted for the entire resulting string.
> This functionality is also used in a javascript project called \[lit\](https://lit.dev/), which is achieved through tagged literals rather than jsx.
> 
> Have we ever talked about introducing tagged literals?
> I would really like to use this in Python, and I would like to see this functionality used in Python.
> 
> \*\*Previous discussion\*\*
> (I cannot found it)
> 
> \<!--
> New features to Python should first be discussed elsewhere before creating issues on GitHub,
> for example in the "ideas" category (https://discuss.python.org/c/ideas/6) of discuss.python.org,
> or the python-ideas mailing list (https://mail.python.org/mailman3/lists/python-ideas.python.org/).
> Use this space to post links to the places where you have already discussed this feature proposal:
> \--\>
> 
> 
> \<!--
> You can freely edit this text. Remove any lines you believe are unnecessary.
> \--\>

---

<div class="post-metadata">

**Author:** ![barry](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barry/32/42_2.png) [@barry](https://discuss.python.org/u/barry)\
**Post date:** [July 26, 2022, 2:56am UTC](https://discuss.python.org/t/add-tagged-template-literals/17685/2 "2022-07-26T02:56:35Z")

</div>

@jimbaker has been talking about a feature like this for a while now, but I don’t think he’s written up a PEP for it yet.

---

<div class="post-metadata">

**Author:** ![petersuter](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@petersuter](https://discuss.python.org/u/petersuter)\
**Post date:** [July 26, 2022, 4:12am UTC](https://discuss.python.org/t/add-tagged-template-literals/17685/3 "2022-07-26T04:12:02Z")

</div>

I think some related previous discussions can be found by searching for “PEP 501”:

- [Custom strings](https://discuss.python.org/t/custom-strings-h/8285/5)
- [Mailman 3 [Python-ideas] Bring back PEP 501 - Python-ideas - python.org](https://mail.python.org/archives/list/python-ideas@python.org/message/5AW73ICBD4CVCRUNISRNAERPPF2KSOGZ/)

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/guido/32/21_2.png) [@guido](https://discuss.python.org/u/guido)\
**Post date:** [July 26, 2022, 8:32pm UTC](https://discuss.python.org/t/add-tagged-template-literals/17685/4 "2022-07-26T20:32:36Z")

</div>

There’s also current work by Jim Baker and Ryan Morshead (with a prototype implementation by myself) towards a PEP that will introduce “tag strings” (tentative name). [GitHub - jimbaker/tagstr: This repo contains an issue tracker, examples, and early work related to PEP 999: Tag Strings](https://github.com/jimbaker/tagstr)

If you want to help I recommend reading through the tracker there.
