Plugins You can find out about all the publicly available Grails plugins.

Smart Case Plugin

0 vote
Dependency:
compile "org.grails.plugins:smart-case:1.4.7"

 Documentation  Source  Issues

Summary

Provides an easy way to convert between cases for Strings and variable names

Installation

compile ':smart-case:x.x.x'

Description

The initial version focuses on formatting Strings, but in the future, the idea is to let you convert from and to:
  • lowerCamelCase
  • UpperCamelCase
  • snake_case
  • SCREAMING_SNAKE_CASE

String Formatting

We are all used to methods like toLowerCase(), toUpperCase() and even capitalize(). And some combination of these lets you format your Strings the way you usually want it. But sometimes you end up having a capital letter where you don't want it or missing one where there should be one.

This plugin adds a new custom codec for title casing your strings by calling this magic method:

String foo = bar.encodeAsTitle()

Here is a comparison with some example phrases:

PhrasetoLowerCase()toUpperCase()capitalize()encodeAsTitle()
HELLO, MY NAME IS MATHIAShello, my name is mathiasHELLO, MY NAME IS MATHIASHELLO, MY NAME IS MATHIASHello, my name is Mathias
united states of americaunited states of americaUNITED STATES OF AMERICAUnited states of americaUnited States of America