buscar las plantillas en window
This commit is contained in:
parent
e0d6870fd7
commit
c41e9df446
2 changed files with 2 additions and 7 deletions
|
@ -15,13 +15,9 @@ export default class extends Controller {
|
||||||
* nothing if the template isn't found.
|
* nothing if the template isn't found.
|
||||||
*/
|
*/
|
||||||
async render (name, data = {}) {
|
async render (name, data = {}) {
|
||||||
const response = await fetch(this.template(name))
|
|
||||||
|
|
||||||
if (!response.ok) return
|
|
||||||
|
|
||||||
data.site = window.site
|
data.site = window.site
|
||||||
|
|
||||||
const template = await response.text()
|
const template = window.templates.alert
|
||||||
const html = await this.engine.parseAndRender(template, data)
|
const html = await this.engine.parseAndRender(template, data)
|
||||||
|
|
||||||
this.element.innerHTML = html
|
this.element.innerHTML = html
|
||||||
|
|
|
@ -48,8 +48,7 @@ export default class extends Controller {
|
||||||
const main = document.querySelector('main')
|
const main = document.querySelector('main')
|
||||||
const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref))
|
const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref))
|
||||||
const site = window.site
|
const site = window.site
|
||||||
const request = await fetch('assets/templates/results.html')
|
const template = window.templates.results
|
||||||
const template = await request.text()
|
|
||||||
const html = await this.engine.parseAndRender(template, { q, site, results })
|
const html = await this.engine.parseAndRender(template, { q, site, results })
|
||||||
const title = `${site.i18n.search.title} - ${q}`
|
const title = `${site.i18n.search.title} - ${q}`
|
||||||
const query = new URLSearchParams({ q })
|
const query = new URLSearchParams({ q })
|
||||||
|
|
Loading…
Reference in a new issue