Includes
Split your apps into multiple files that you can import/insert into one another.
Includes allows you to move parts of your application into separate files. Includes (like the name suggests) simply inserts code from other files into another. The place where you use the include keyword will be the location to which the code will be inserted to.
Usage
Any .ask file can be treated as an include. You don't need to add anything special into include modules. Simple insert their contents into another .ask file using the include
keyword.
Example
main.ask
@get('/a/1'):
respond('Hello from A1')
@get('/a/2'):
respond('Hello from A2')
include module_b
module_b.ask
@get('/b/1'):
respond('Hello from B1')
@get('/b/2'):
respond('Hello from B2')
(Result) (app.ask)
@get('/a/1'):
respond('Hello from A1')
@get('/a/2'):
respond('Hello from A2')
@get('/b/1'):
respond('Hello from B1')
@get('/b/2'):
respond('Hello from B2')
Include module paths
You can put include modules in the same directory as you're importing them from. You can also put them in sub-folders, and point to their paths using dots (like slashes in normal file paths)
File structure
- main.ask
- modules/
- module_b.ask
Pointing to sub-folders
include modules.module_b
Last updated