Coder Social home page Coder Social logo

heist_getting_started's Introduction

Trying (and Failing) to Use Heist

This repository was created to accompany this short series of blog posts.

Getting Started

If you have Nix you can do nix develop followed by cabal run. If you don't have Nix, you can also just run cabal run granted that GHC is available. At the time of writing I'm using GHC 9.4.6.

Problem

I want to create a minimal example of how to use the Heist templating system without using Snap. It should use compiled Heist.

The general idea of what the code is supposed to do is:

  1. Load and precompile all templates
  2. Make a fake database call outside of any splice/template/Heist functions
  3. Apply the precompiled templates to data

It seems to me that Heist really does not want you to fetch data in any other way than through runtime splices that access your application monad. If you look at Main.hs and focus on the commented out lines you can hopefully see where I'm stuck and why this doesn't look like it's possible with Heist.

I have two templates, that have the <foo /> tag/splice in common, but also each have one other piece of data. In Main.hs, I'd like to be able to render either of the two views with exactly the data it needs. I do not want mainSplices to become an amalgamation of all the types required by both views. I don't want to have any (fake) database calls in code that mentions splices (or any other Heist related code)

heist_getting_started's People

Contributors

cidem avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.