Login

Snippets by phxx

Snippet List

Python-like string interpolation in Javascript

Provides python-like string interpolation. It supports value interpolation either by keys of a dictionary or by index of an array. Examples: interpolate("Hello %s.", ["World"]) == "Hello World." interpolate("Hello %(name)s.", {name: "World"}) == "Hello World." interpolate("Hello %%.", {name: "World"}) == "Hello %." This version doesn't do any type checks and doesn't provide formating support.

  • template
  • javascript
  • string interpolation
  • replace
Read More

Default settings for a app

Save this as conf.py in the app's directory. Now you can do `from myapp.conf import settings`. You can access from the imported object every item of your settings.py including the default settings of myapp. Though you don't have to define every setting in settings.py you use in your app. Now you can ommit annoying try...except statements to define defaults directly in the code.

  • settings
  • conf
  • app
Read More

phxx has posted 2 snippets.