|
| 1 | +# Template Engine with Encore.ts |
| 2 | + |
| 3 | +This example utilizes a Raw endpoint to serve views through a template engine. The example implementation uses [EJS](https://ejs.co/) for rendering views, but the same approach is also applicable for other template engines. |
| 4 | + |
| 5 | +## Developing locally |
| 6 | + |
| 7 | +### Prerequisite: Installing Encore |
| 8 | + |
| 9 | +If this is the first time you're using Encore, you first need to install the CLI that runs the local development |
| 10 | +environment. Use the appropriate command for your system: |
| 11 | + |
| 12 | +- **macOS:** `brew install encoredev/tap/encore` |
| 13 | +- **Linux:** `curl -L https://encore.dev/install.sh | bash` |
| 14 | +- **Windows:** `iwr https://encore.dev/install.ps1 | iex` |
| 15 | + |
| 16 | +When you have installed Encore, run: |
| 17 | + |
| 18 | +```bash |
| 19 | +encore app create --example=ts/template-engine |
| 20 | +``` |
| 21 | + |
| 22 | +## Running locally |
| 23 | + |
| 24 | +```bash |
| 25 | +encore run |
| 26 | +``` |
| 27 | + |
| 28 | +**Pages:** |
| 29 | + |
| 30 | +- <http://localhost:4000/person> - Serving a specific view with data |
| 31 | +- <http://localhost:4000/> - Serving a template based on the dynamic path |
| 32 | +- <http://localhost:4000/about/contact> - Serving a template located in a sub-folder |
| 33 | +- <http://localhost:4000/html> - Serving an inline HTML template |
| 34 | + |
| 35 | +Open [http://localhost:4000](http://localhost:4000) in your browser to see the example frontend. |
| 36 | + |
| 37 | +You can also access Encore's [local development dashboard](https://encore.dev/docs/observability/dev-dash) on <http://localhost:9400/> to view traces, API documentation, and more. |
| 38 | + |
| 39 | +## Deployment |
| 40 | + |
| 41 | +Deploy your application to a staging environment in Encore's free development cloud: |
| 42 | + |
| 43 | +```bash |
| 44 | +git add -A . |
| 45 | +git commit -m 'Commit message' |
| 46 | +git push encore |
| 47 | +``` |
| 48 | + |
| 49 | +Then head over to the [Cloud Dashboard](https://app.encore.dev) to monitor your deployment and find your production URL. |
| 50 | + |
| 51 | +From there you can also connect your own AWS or GCP account to use for deployment. |
| 52 | + |
| 53 | +Now off you go into the clouds! |
0 commit comments