Skip to content

TwigException: Cannot extend an inline template. #99

@ghost

Description

Not sure if this is the correct place.

I try to use twig.js with koa 2:

const Views = require('koa-views');

app.use(Views('./views', {
	map: {
		twig: 'twig'
	},
	extension: 'twig'
}));

app.use(Route.get('/', async(ctx) => {
	await ctx.render('pages/home');
}));

Now i'll try to use a layout

layout.twig:

<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title>Hello World!</title>
</head>

<body>
	{% block body %}{% endblock %}
</body>

</html>

home.twig

{% extends "../layout.twig" %}

{% block body %}
    Hello World
{% endblock %}

Now i'm getting this error:

Error parsing twig template undefined:
TwigException: Cannot extend an inline template.

  Error: non-error thrown: TwigException: Cannot extend an inline template.
      at Object.onerror (C:\Users\jerom\Documents\programming\test\node_modules\koa\lib\context.js:107:40)
      at onerror (C:\Users\jerom\Documents\programming\test\node_modules\koa\lib\application.js:133:34)

Anyone an idea what i did wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions