Skip to content

Context Functions

The following libraries have been added to the context under “h”.

Refer to them for any functions you would like to use:

  • inflection A package to transform english strings into other forms like the plural form, singular form, camelCase form, etc.
  • change-case Transform a string between camelCase, PascalCase, Capital Case, snake_case, kebab-case, CONSTANT_CASE and others.

You use them like: <%= h.changeCase.pascalCase(name) %> <%= h.inflection.pluralize(name) %>

Here is a quick summary for reference which may not be current:

Inflection

inflection.pluralize( str, plural ); inflection.singularize( str, singular ); inflection.inflect( str, count, singular, plural ); inflection.camelize( str, low_first_letter ); inflection.underscore( str, all_upper_case ); inflection.humanize( str, low_first_letter ); inflection.capitalize( str ); inflection.dasherize( str ); inflection.titleize( str ); inflection.demodulize( str ); inflection.tableize( str ); inflection.classify( str ); inflection.foreign_key( str, drop_id_ubar ); inflection.ordinalize( str ); inflection.transform( str, arr );

change-case

MethodResult
camelCasetwoWords
capitalCaseTwo Words
constantCaseTWO_WORDS
dotCasetwo.words
kebabCasetwo-words
noCasetwo words
pascalCaseTwoWords
pascalSnakeCaseTwo_Words
pathCasetwo/words
sentenceCaseTwo words
snakeCasetwo_words
trainCaseTwo-Words