Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Templating with Twig!
You have completed Templating with Twig!
Preview
Macros can be defined in any template, and need to be "imported" via the import tag before being used.
Macros can be defined in any template, and need to be "imported" via the import tag before being used:
{% import "forms.twig" as forms %}
<form method="post">
{{ forms.input('name', post.name) }}
{{ forms.input('email', post.email, 'text', "We'll never share your email with anyone else.") }}
{{ forms.textarea('message') }}
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We're going to add a form tag,
we're gonna set the method = post.
0:00
And we'll let it submit back here for now.
0:01
Form, and we'll add our submit button.
0:04
Submit, class= btn btn-primary,
0:12
and then Send Message, button.
0:20
Okay, before our form,
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up