IHP Api Reference
Copyright(c) digitally induced GmbH 2020
Safe HaskellNone

IHP.NameSupport

Description

 
Synopsis

Documentation

tableNameToModelName :: Text -> Text Source #

Transforms a underscore table name to a camel case model name.

>>> tableNameToModelName "users"
"User"
>>> tableNameToModelName "projects"
"Project"

columnNameToFieldName :: Text -> Text Source #

Transforms a underscore table column name to a camel case attribute name for use in haskell.

>>> columnNameToFieldName "email"
"email"
>>> columnNameToFieldName "project_id"
"projectId"

modelNameToTableName :: Text -> Text Source #

Transforms a camel case model name to a underscored table name.

>>> modelNameToTableName "User"
"users"
>>> modelNameToTableName "UserProject"
"user_projects"

humanize :: Text -> Text Source #

Returns a more friendly version for an identifier

ucfirst :: Text -> Text Source #

Make a text's first character uppercase

>>> ucfirst "hello world"
"Hello World"
>>> ucfirst "Already uppercase"
"Already uppercase"

lcfirst :: Text -> Text Source #

Make a text's first character lowercase

>>> lcfirst "Hello World"
"hello World"
>>> lcfirst "alread lowercase"
"already lowercase"

fieldNameToColumnName :: Text -> Text Source #

Transforms a camel case attribute name from haskell to a underscore table column name for the database.

>>> fieldNameToColumnName "email"
"email"
>>> fieldNameToColumnName "projectId"
"project_id"

escapeHaskellKeyword :: Text -> Text Source #

Add '_' to the end of a name if it is a reserved haskell keyword

>>> escapeHaskellKeyword "test"
"test"
>>> escapeHaskellKeyword "type"
"type_"

tableNameToControllerName :: Text -> Text Source #

Transforms a underscore table name to a name for a controller

>>> tableNameToControllerName "users"
"Users"
>>> tableNameToControllerName "projects"
"Projects"
>>> tableNameToControllerName "user_projects"
"UserProjects"

tableNameToViewName :: Text -> Text Source #

Transforms an underscore table name to a name for a view

>>> tableNameToViewName "users"
>>> tableNameToViewName "projects"
>>> tableNameToViewName "user_projects"

enumValueToControllerName :: Text -> Text Source #

Transforms a enum value to a name for a model

>>> enumValueToControllerName "happy"
"Happy"
>>> enumValueToControllerName "very happy"
"VeryHappy"
>>> enumValueToControllerName "very_happy"
"VeryHappy"

toSlug :: Text -> Text Source #

Transforms a string to a value to be safely used in urls

>>> toSlug "IHP Release: 21.08.2020 (v21082020)"
"ihp-release-21-08-2020-v21082020"
>>> toSlug "Hallo! @ Welt"
"hallo-welt"

fieldNameToFieldLabel :: Text -> Text Source #

Transform a data-field name like userName to a friendly human-readable name like User name

>>> fieldNameToFieldLabel "userName"
"User name"

columnNameToFieldLabel :: Text -> Text Source #

Transform a column name like user_name to a friendly human-readable name like User name

>>> columnNameToFieldLabel "user_name"
"User name"

removeIdSuffix :: Text -> Text Source #

Removes Id from a string

>>> removeIdSuffix "User Id"
"User"

When the string does not end with Id, it will just return the input string:

>>> removeIdSuffix "Project"
"Project"