Giter Club home page Giter Club logo

karver's People

Contributors

sourrust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ibotty

karver's Issues

Improve if statements

As of commit 7f62a10, karver only evaluates logic of the if statement as a check for a variable's existence.

Example:

{% if title %}
  <title>{{ title }}</title>
{% else %}
  <title>No Title</title>
{% endif %}

It would be nice to implement some of the suggested features list in said comment.

That list being:

  • basic logically comparisons (is (==), isnt (/=), >, <, >=, <=)
  • elseif expressions
  • format the inside of the if statement better (ie. indention)

ghc: could not execute: hspec-discover

Hello !

I played a bit with your package; I could run a simple program with json data so I am quite happy :)

However I could not build the tests.
I am working on the master branch (commit 187b0a2)

$ cabal configure --enable-tests
Resolving dependencies...
Configuring karver-0.1.0...
$ cabal build
Building karver-0.1.0...
Preprocessing library karver-0.1.0...
In-place registering karver-0.1.0...
Preprocessing test suite 'spec' for karver-0.1.0...
ghc: could not execute: hspec-discover
damien@grigny:~/src/karver(master)$ cabal list hspec

  • hspec
    Synopsis: Behavior-Driven Development for Haskell
    Default available version: 1.7.0
    Installed versions: 1.7.0
    Homepage: http://hspec.github.io/
    License: MIT
    (snip)

regards,
Damien

The Value data type is too limited

I wonder why the Object constructor in the Value data type holds a map of Text to Text, not Text to Values?

data Value = Literal Text | Object (HashMap Text Text) | List   (Vector Value)

It does not allow nested objects and is too limited for many use cases. I wonder if it is on purpose of something that can be considered as an improvment?

avoid unsafePerformIO

what do you think about the following approach.

renderTemplate'' :: Monad m => (Text -> m Text) -> HashMap Text Value -> Text -> m Text

where the function Text -> m Text can be e.g. TIO.readFile . T.unpack for the current behavior or return . fromJust . flip lookup myIncludesMap for a pure approach.

of course these are partial, but so is renderTemplate today. i will file a new bug about it separately. of course that signature should change as well, when a total function is desired.

Escape brackets

In my template I am using the character '{' and it seems to cause the rest of the template to be ignored. Removing it everything is fine.

Incorrect Indentation

For expression parsers, like conditionParser and loopParser, the indentation is incorrect. And as a result, so are the tests when it comes to multi line parsing.

For test like this for loop, there shouldn't be an extra \n and the indention is lost as well. Expected text should really be something like:

let expected = unlines [ "Some libraries used:"
                       , "  * attoparsec"
                       , "  * hspec"
                       ]

The other example is the multi line if else statement. What should be expected is:

let expected = Right $ ConditionTok "title" "  {{ title }}\n" "  title\n"

This problem is also reference in issue #1.

make `renderTemplate` total

right now a non-existent include raises an error and parse errors or lookup errors in the context will just render nonsensical text without the calling application being aware of it.

i would need renderTemplate to return Either KarverError Text with a suitable data KarverError = InvalidTemplate LineNo ColumnNo Text | NoSuchInclude Text | ....

i propose the following change to renderTemplate, so that the current behavior is still possible. add another argument to renderTemplate that decides what to do. e.g. renderTemplate :: (KarverError -> Either a Text) -> HashMap Text Value -> Text -> Either a Text.

what do you think?

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.