pyrocms/pyrocms — pull request #1323 by chadwithuhc (2012-04-12 06:04:12+00:00)
Title: Updated pyro.generate_slug() to allow custom space converter

1. Updated pyro.generate_slug() to allow a third parameter for changing the default dash to something else like underscore: `pyro.generate_slug(input, output, '_')` will convert `This text is awe-some` to `this_text_is_awe-some`; preserves dashes in this case since a word might be something like "tongue-in-cheek"
2. Changed the function to disallow the space character at the beginning or end of the slug. Example: `This text is awesome...` used to produce `this-text-is-awesome-`. Now it produces `this-text-is-awesome`.

These changes were implemented to allow people using PyroSnippets to generate a slug without dashes since calling `{{ snippet:some-var-name }}` would error out. This function can also now be used to replace `slugify()` which is a JS function used in Streams for slug fields. The `slugify()` function does not support as many characters as the `pyro.generate_slug()` function.

If this goes through, I can change those old functions to the new one, as well as create an additional function that will simply take and convert text without automatically duplicating it to a new field.