@views

Configure the location of view code. Architect copies view code to all HTTP GET handler functions by default. You can also specify only the routes you want views copied to with the @views pragma. For a full example, see Sharing Code.

Syntax

  • Routes should be existing @http routes.
  • Route names follow the same requirements as @http routes. see @http

Example

This app.arc file defines specific @http functions to copy src/views/ to:

arc
@app
myapp

@http
get /
get /kittens
get /dogs
get /raccoons

@views
get /kittens
get /raccoons
json
{
  "app": "myapp",
  "http": [
    [ "get", "/" ],
    [ "get", "/kittens" ],
    [ "get", "/dogs" ],
    [ "get", "/raccoons" ]
  ],
  "views": [
    [ "get", "/kittens" ],
    [ "get", "/raccoons" ]
  ]
}
yaml
---
app: testapp

http:
- get: "/"
- get: "kittens"
- get: "dogs"
- get: "raccoons"

views:
- get: "kittens"
- get: "raccoons"

Specific function opt-out

A function can be configured with a config.arc to not have @views code automatically hydrated.