Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- interpolate' :: (MonadIO m, MustacheBackend b) => InterpolationMode -> InterpreterInstance -> b -> SourceLocation -> Text -> SqlTemplateVariables -> m (Either InterpolationError Text)
- interpolate :: MonadIO m => InterpolationMode -> SourceLocation -> Text -> SqlTemplateVariables -> m (Either InterpolationError Text)
- initInterpreterForMustache :: MonadIO m => LogOptions -> m InterpreterInstance
Documentation
interpolate' :: (MonadIO m, MustacheBackend b) => InterpolationMode -> InterpreterInstance -> b -> SourceLocation -> Text -> SqlTemplateVariables -> m (Either InterpolationError Text) #
Substitutes variables in mustache template. Supports Haskell function interpolation in form of mustache sections.
For example, following mustache template:
select {{#selExp}}[nonAlias $ varString ("column_" ++ show n) | n <- [1..3]]{{/selExp}} from dual
will be converted to
select "column_1", "column_2", "column_3" from dual
when using Postgres
, but to
selectcolumn_1
,column_2
,column_3
from dual
when using BigQuery
as a backend.
Full list of supported sections:
- sExp - generates
SExp
- almost any term in SQL syntax isSExp
- selExp - generates [
Alias
SExp
] - represents one or many select clauses - fromExp - generates
From
- represents a relation with attached "from" keyword - relAsExp - generates
Relation
- represents a relation without an alias - relExp - generates
Alias
Relation
- represents a relation with its alias - queryExp - generates
Query
- full SQL query - strExp - generates
String
- will be inserted as is
:: MonadIO m | |
=> InterpolationMode | Level of interpoaltion engine strictness |
-> SourceLocation | Location of the template (important for error reporting) |
-> Text | Text of the template |
-> SqlTemplateVariables | List of variables to use for a substitution process |
-> m (Either InterpolationError Text) |
Substitutes variables in mustache template. Does not supports Haskell function interpolation.
initInterpreterForMustache :: MonadIO m => LogOptions -> m InterpreterInstance #
Creates an instance of the Haskell interpreter to use for Mustache templating purposes.