djangosnippets.org: Latest snippets tagged with 'string interpolation'https://djangosnippets.org/tags/string-interpolation/2010-06-20T09:04:49.088575-05:00Python-like string interpolation in Javascript
2010-06-20T09:04:49.088575-05:00phxxhttps://djangosnippets.org/snippets/2074/<p>Provides python-like string interpolation.
It supports value interpolation either by keys of a dictionary or
by index of an array.</p>
<p>Examples:</p>
<pre><code> interpolate("Hello %s.", ["World"]) == "Hello World."
interpolate("Hello %(name)s.", {name: "World"}) == "Hello World."
interpolate("Hello %%.", {name: "World"}) == "Hello %."
</code></pre>
<p>This version doesn't do any type checks and doesn't …</p>
Freely redistributable