Embed form
via
{% set _path = handler.request.uri.split('/form/')[0] %} {% set _url = handler.request.protocol + '://' + handler.request.host + _path %} {% set view_url = _url + "/embed/" + form_id %}

Embed form

You can use any of the methods below to render the form. Note the file extensions in each of the approaches below.

Using JavaScript

Below code renders the form in place.

                <link rel="stylesheet" href="{{ _url }}/ui/bootstrap/dist/css/bootstrap.min.css">
<script src="{{ _url }}/ui/jquery/dist/jquery.min.js"></script>
<div class="container">
  <form>
    <script src="{% raw view_url + '.js' %}"></script>
  </form>
</div>

Using HTML

Below code renders the form in .form-container element.

                <link rel="stylesheet" href="{{ _url }}/ui/bootstrap/dist/css/bootstrap.min.css">
<div class="container">
  <form></form>
</div>
<script src="{{ _url }}/ui/jquery/dist/jquery.min.js"></script>
<script>
  $('.container form').load("{% raw view_url + '.html' %}")
</script>
              

Server-side rendering

Below snippet is a Gramex server-side rendering example which renders the form in place.

                <link rel="stylesheet" href="{{ _url }}/ui/bootstrap/dist/css/bootstrap.min.css">
                  {%! import requests %}
                  <form>
                  {%! raw requests.get('{{ view_url + '.html' }}').text %}
                  </form>
                
              

Link