diff --git a/compiler/main.v b/compiler/main.v index e968d5e00a..364453bb4d 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -71,7 +71,7 @@ mut: out_name string // "program.exe" vroot string mod string // module being built with -lib - //parsers []Parser + parsers []Parser } struct Preferences { @@ -206,6 +206,16 @@ fn main() { } } +fn (v mut V) add_parser(parser Parser) { + for p in v.parsers { + if p.file_path == parser.file_path { + return + } + } + v.parsers << parser +} + + fn (v mut V) compile() { // Emily: Stop people on linux from being able to build with msvc if os.user_os() != 'windows' && v.os == .msvc { diff --git a/examples/vweb/index.html b/examples/vweb/index.html index 4c3420f04d..1fbd30b049 100644 --- a/examples/vweb/index.html +++ b/examples/vweb/index.html @@ -1 +1,5 @@ test app + +
+ +
diff --git a/examples/vweb/test_app.v b/examples/vweb/test_app.v index 49d71fa9ba..5e65e141fd 100644 --- a/examples/vweb/test_app.v +++ b/examples/vweb/test_app.v @@ -9,6 +9,7 @@ const ( struct App { pub mut: vweb vweb.Context // TODO embed + cnt int } fn main() { @@ -23,11 +24,11 @@ pub fn (app mut App) json_endpoint() { app.vweb.json('{"a": 3}') } -/* pub fn (app mut App) index() { - $vweb.html() + app.cnt ++ + + $vweb.html() } -*/ pub fn (app mut App) text() { app.vweb.text('hello world') @@ -38,4 +39,4 @@ pub fn (app mut App) cookie() { app.vweb.set_cookie('cookie', 'test') app.vweb.text(app.vweb.headers) app.vweb.text('Text: hello world') -} \ No newline at end of file +}