cometa/src/options.ts

84 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-01-19 18:52:30 +01:00
export const enum LOG_TYPE {
Info,
Warning,
Error,
}
2018-02-06 20:00:09 +01:00
export function isRender(obj: any): obj is Render {
return typeof obj === 'string'
}
export type Render = string
export type Part = (PartFunction | Render)
export type PartFunction = (data: any) => (Part[] | Render)
export interface ActionReturn {
parts: Part[]
length: number
}
export type ActionFunction = (part: Render) => ActionReturn
export interface Compiled {
template: Part[]
2018-01-19 18:52:30 +01:00
hash: string
time: number
}
2018-02-06 20:00:09 +01:00
export const error = {
parse: {
default: 'Parse Error.',
import_recursion: 'Maximal recusion achieved in import module',
not_supported: 'Not supported yet',
comment_not_closed: 'Comment was not closed properly',
variable_not_closed: 'Variable was not closed properly',
include_not_closed: 'Include not closed',
},
2018-01-19 18:52:30 +01:00
}
interface Options {
encoding: string
caching: boolean
template_dir: string
template_ext: string
compiled_dir: string
compiled_ext: string
2018-01-21 22:59:05 +01:00
max_recursion: number
2018-01-19 18:52:30 +01:00
}
export const options: Options = {
encoding: 'utf-8',
caching: true,
template_dir: './views',
template_ext: 'html',
2018-02-06 20:00:09 +01:00
compiled_dir: './cache',
compiled_ext: 'bjs',
2018-01-21 22:59:05 +01:00
max_recursion: 100,
2018-01-19 18:52:30 +01:00
}
interface Expressions {
begin: string
ending: string
comment: string
incude: string
if: string
if_else: string
2018-02-06 20:00:09 +01:00
if_invert: string
2018-01-19 18:52:30 +01:00
for: string
for_in: string
2018-02-06 20:00:09 +01:00
closing_tag: string
2018-01-19 18:52:30 +01:00
}
export const re: Expressions = {
begin: '{{',
ending: '}}',
comment: '#',
incude: '>',
if: '?',
if_else: '!',
2018-02-06 20:00:09 +01:00
if_invert: '!',
2018-01-19 18:52:30 +01:00
for: '*',
for_in: 'in',
2018-02-06 20:00:09 +01:00
closing_tag: '/',
2018-01-19 18:52:30 +01:00
}