|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||
java.lang.Objectjava.lang.Enum<StringHelpers>
com.github.jknack.handlebars.StringHelpers
public enum StringHelpers
Commons string function helpers.
| Enum Constant Summary | |
|---|---|
ABBREVIATE
Truncates a string if it is longer than the specified number of characters. |
|
CAPITALIZE
Capitalizes all the whitespace separated words in a String. |
|
CAPITALIZE_FIRST
Capitalizes the first character of the value. |
|
CENTER
Centers the value in a field of a given width. |
|
CUT
Removes all values of arg from the given string. |
|
DATE_FORMAT
Usage: |
|
DEFAULT
If value evaluates to False, uses the given default. |
|
JOIN
Joins a list with a string, like Python's str.join(list) For example: |
|
LJUST
Left-aligns the value in a field of a given width. |
|
LOWER
Converts a string into all lowercase. |
|
RJUST
Right-aligns the value in a field of a given width. |
|
SLUGIFY
Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. |
|
STRING_FORMAT
Formats the variable according to the argument, a string formatting specifier. |
|
STRIP_TAGS
Strips all [X]HTML tags. |
|
UPPER
Converts a string into all lowercase. |
|
WORD_WRAP
Wraps words at specified line length. |
|
YESNO
Maps values for true, false and (optionally) null, to the strings "yes", "no", "maybe". |
|
| Method Summary | |
|---|---|
String |
helperName()
Return the helper's name. |
static void |
register(Handlebars handlebars)
Regiter all the text helpers. |
static StringHelpers |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static StringHelpers[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| Methods inherited from class java.lang.Enum |
|---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.github.jknack.handlebars.Helper |
|---|
apply |
| Enum Constant Detail |
|---|
public static final StringHelpers CAPITALIZE_FIRST
{{capFirst value}}
If value is "handlebars.java", the output will be "Handlebars.java".
public static final StringHelpers CENTER
{{center value size=19 [pad="char"] }}
If value is "Handlebars.java", the output will be " Handlebars.java ".
public static final StringHelpers CUT
{{cut value [" "]}}
If value is "String with spaces", the output will be "Stringwithspaces".
public static final StringHelpers DEFAULT
{{default value ["nothing"] }}
If value is "" (the empty string), the output will be nothing.
public static final StringHelpers JOIN
{{join value " // " [prefix=""] [suffix=""]}}
If value is the list ['a', 'b', 'c'], the output will be the string
"a // b // c".
public static final StringHelpers LJUST
{{ljust value 20 [pad=" "] }}
If value is Handlebars.java, the output will be "Handlebars.java ".
public static final StringHelpers RJUST
{{rjust value 20 [pad=" "] }}
If value is Handlebars.java, the output will be " Handlebars.java".
public static final StringHelpers LOWER
{{lower value}}
If value is 'Still MAD At Yoko', the output will be 'still mad at yoko'.
public static final StringHelpers UPPER
{{upper value}}
If value is 'Hello', the output will be 'HELLO'.
public static final StringHelpers SLUGIFY
{{slugify value}}
If value is "Joel is a slug", the output will be "joel-is-a-slug".
public static final StringHelpers STRING_FORMAT
{{stringFormat string param0 param1 ... paramN}}
If value is "Hello %s" "handlebars.java", the output will be
"Hello handlebars.java".
String.format(String, Object...)public static final StringHelpers STRIP_TAGS
{{stripTags value}}
public static final StringHelpers CAPITALIZE
{{ capitalize value [fully=false]}}
If value is "my first post", the output will be "My First Post".
public static final StringHelpers ABBREVIATE
{{abbreviate value 13 }}
If value is "Handlebars rocks", the output will be "Handlebars...".
public static final StringHelpers WORD_WRAP
{{ wordWrap value 5 }}
If value is Joel is a slug, the output would be:
Joel is a slug
public static final StringHelpers YESNO
{{yesno value [yes="yes"] [no="no"] maybe=["maybe"] }}
public static final StringHelpers DATE_FORMAT
Usage:
{{dateFormat date ["format"]}}
Format parameters is one of:
| Method Detail |
|---|
public static StringHelpers[] values()
for (StringHelpers c : StringHelpers.values()) System.out.println(c);
public static StringHelpers valueOf(String name)
name - the name of the enum constant to be returned.
IllegalArgumentException - if this enum type has no constant
with the specified name
NullPointerException - if the argument is nullpublic String helperName()
public static void register(Handlebars handlebars)
handlebars - The helper's owner.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||