Caleb Kleveter Caleb Kleveter - 7 days ago 6
HTML Question

ParseError.tagTemplateNotFound("short\").val")

I am working on a very simple Vapor app. I am currently working on one of the views:

#extend("base")

#export("body") {
<form>
<div class="row">
<div class="six columns">
<label for="exampleEmailInput">Acronym</label>
<input class="u-full-width" type="email" id="short">
</div>
<div class="six columns">
<label for="exampleRecipientInput">Long form</label>
<input class="u-full-width" type="email" id="long">
</div>
</div>
</form>
<div class="row">
<div class="five columns"></div>
<div class="two columns">
<a class="button button-primary" id="submit" href="/acronym/all">Save Acronym</a>
</div>
<div class="five columns"></div>
</div>
<script>
function setHref() {
var short = $("#short").val();
}
</script>
}


This code works until I add the
short
variable to the
setHref
function. Then I get a parsing error:

Uncaught Error: ParseError.tagTemplateNotFound("short\").val"). Use middleware to catch this error and provide a better response. Otherwise, a 500 error page will be returned in the production environment.


Why is this happening?

Answer

Leaf is finding #short and parsing it as a tag. My guess is you're looking for some type of escaping mechanism. Here's some options:

#()short => #short
#raw() { #short } => #short