forked from adonisjs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobals.js
More file actions
28 lines (23 loc) · 835 Bytes
/
globals.js
File metadata and controls
28 lines (23 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict'
/**
* adonis-framework
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const Form = require('./Form')
module.exports = function (env, Route) {
env.addGlobal('form', new Form(env, Route))
env.addGlobal('linkTo', function (route, text, options, target) {
const url = env.filters.route(route, options)
target = target ? `target="${target}"` : ''
return env.filters.safe(`<a href="${url}" ${target}> ${text} </a>`)
})
env.addGlobal('linkToAction', function (action, text, options, target) {
const url = env.filters.action(action, options)
target = target ? `target="${target}"` : ''
return env.filters.safe(`<a href="${url}" ${target}> ${text} </a>`)
})
}