martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
415 stars 22 forks source link

Add a `csrf_input` template tag #200

Closed ellmetha closed 4 months ago

ellmetha commented 7 months ago

Description

Marten already provides a csrf_token template tag in order to generate the CSRF token value and access it in templates. Let's also introduce a csrf_input template tag that will make it easy to generate the following form input containing the CSRF token:

<input type="hidden" name="csrftoken" value="{{ csrf_token }}" />

This will make it easier to write forms containing a CSRF token input and not bother about possible typos regarding the input name.