Questions tagged [leaf]

For questions regarding the Leaf templating language that is used with the Vapor web framework

A description of Leaf from the documentation:

Leaf's goal is to be a simple templating language that can make generating views easier. There's a lot of great templating languages, use what's best for you, maybe that's leaf! The goals of leaf are as follows:

  • Small set of strictly enforced rules
  • Consistency
  • Parser first mentality
  • Extensibility

It was built specifically for the Vapor web framework that is used to create web apps with Swift.

Top questions:

69 questions
2
votes
1 answer

How to assign variable in Vapor leaf?

I have a temple that render a table using a struct that represents all the data. The template look like this.
DataTables…
Terrick Mansur
  • 147
  • 1
  • 10
2
votes
1 answer

Javascript function in vapor 3 leaf - Help Need

I have a Javascript function in a leaf page using Vapor 3 the function should trigger a post to an api to save a customers card detials and return a token representing that card. I would normally do this in swift on our vapor server but to be PCI…
Joby Ingram-Dodd
  • 730
  • 5
  • 23
2
votes
1 answer

Swift Vapor - 'Cannot invoke 'add' with an argument list of type...' errors in configure.swift

I am doing an e-commerce tutorial from Paul Hudson on YouTube. I am getting following errors in configure.swift: import FluentSQLite import Vapor import Leaf // added /// Called before your application initializes. public func configure(_ config:…
askit
  • 205
  • 4
  • 21
2
votes
2 answers

swift vapor leaf loop

I am trying to get a very simple result from a leaf renderer for a for loop with swift vapor. I am uploading leaf file HTML as it is not accepting the code here in correct format - pizza.swift code below - import Foundation import Vapor …
askit
  • 205
  • 4
  • 21
2
votes
1 answer

making custom 404 page Vapor 3

I'd like to make a custom leaf page when I get 404 in Vapor 3.1.0. I've searched the web for it and even in the docs, I couldn't find out. How could I do it? Thank you
Quentin C
  • 307
  • 3
  • 13
2
votes
1 answer

Swift vapor 3 ViewRenderer error

That's the error Please choose which ViewRenderer you prefer, multiple are available: PlaintextRenderer, LeafRenderer. that's my code in configure.swift try services.register(LeafProvider()) config.prefer(LeafRenderer.self, for:…
mercury
  • 2,390
  • 3
  • 30
  • 39
2
votes
1 answer

How to pass data from using POST/form leaf template?

I have a couple of major gaps in my understanding of vapor/leaf/html. I am working from the "todo" example that is created using the beta branch of vapor. First, I made my own fluent model (no problems that I know of): import FluentSQLite import…
Narwhal
  • 744
  • 1
  • 8
  • 22
2
votes
0 answers

Sorting latest time and date using leaf #loop and custom tag using MySql. Vapor, Fluent

I have an issue with sorting date new first using Tag in leaf, vapor. From MySQL database, its showing the date and time but new entry at the end when I use "get" in routes.swift and perfectly show date and time in HTML on the webpage. My each…
2
votes
3 answers

What's the best way to return a collection of response representable objects in Swift Vapor?

Context: Recently, I've decided to take up Swift server side development because I think the Vapor framework is extremely cool. I've gotten a bit stuck while experimenting and would like some advice on templating with leaf and vapor. I've reviewed…
Charles Kenney
  • 360
  • 3
  • 12
2
votes
1 answer

html highlighting for .leaf files with Brackets

Title (almost) says it all. I'm using Brackets 1.9 as my text editor. Now that I'm playing around with Vapor and using Leaf as a templating language. I would like to do syntax coloring/predicting in my .leaf files while editing them with Brackets. I…
Glenn
  • 2,808
  • 2
  • 24
  • 30
2
votes
1 answer

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") {
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
1
vote
1 answer

Unable to Retrieve Country Information When User Selects a Country on the Map

I'm facing an issue with my map-based application where I'm attempting to retrieve country information when a user clicks or selects a specific country on the map. However, despite my efforts, I'm not getting the expected results. I'm seeking…
Israphel
  • 11
  • 1
1
vote
1 answer

How to add a class to the body tag in a Leaf base template

I'm building a site with Vapor and using the Leaf templating engine. Say I have the following base template defined in Base.leaf: #(title)
Jake Strickler
  • 364
  • 2
  • 11
1
vote
0 answers

Vapor / Leaf | Pass DB-Data to Leaf-View throws a FatalError (superEncoder)

I' am new to Vapor and Leaf. I have defined a route that should query data from the DB and pass it to a view. The problem: As soon as I call this route I get a fatal error in the LeadEncoder File Row 162 (superEncoder Function). Here is a…
PsKinggood
  • 43
  • 6
1
vote
1 answer

Updating multiples files with Vapor properly

I'm working on a project with vapor and I'm trying to make a function who edit an item with multiples pictures and I don't know how to make it properly for making update the pictures. Currently, my func is really really lengthy (200 lines :o and I…