GithubHelp home page GithubHelp logo

obadakhalili / sprightly Goto Github PK

View Code? Open in Web Editor NEW
31.0 31.0 3.0 124 KB

๐Ÿ’ก A very light-weight JS template engine

JavaScript 2.76% Shell 0.64% TypeScript 96.60%
expressjs inject-variables partials template-engine

sprightly's People

Contributors

obadakhalili 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sprightly's Issues

Support ExpressJS

Read this to understand express's template engine invocation logic.

The package should provide a .__express API that maps to invoking the sprightly engine with the default parameters. Also, there should be another API for users to pass options for the engine.

The first API is invoked directly by express and the user doesn't have to know about it. The second one the user sets it up using the syntax:

app.engine("html", <call to a function that returns the sprightly engine function loaded with the passed options>);

Write docs

Write the documentation in the README.md file.

Rewrite Sprightly's engine

Make sure that the rewrite achieves the following:

  • The engine should be written in TS.
  • Follow a functional approach to implement the engine, as opposed to the OOP one implemented currently.
  • Use JS's new method .replaceAll() to implement the transformation logic.
  • Currently, if you have the views directory set to ./views and the dir is laid out as follows:
./views
+- file.spy
+- subfolder
+---- nested-file.spy

If subfolder/nested-file.spy wanted to include file.spy as a partial, it would have to reference it as follows ./file.spy instead of ../file.spy (since it's one level up in the tree) because the files are resolved relative to the pre-set ./views directory. You need to fix this behavior and implement the correct one mentioned first.

  • Implement a good error tracing strategy.
  • Implement a caching strategy.
  • Support escaping syntax.
  • The API should take the form:
function sprightly(
  entryPoint: string,
  data: Record<string, string>,
  options: { cache: boolean }
): Promise<string> {
  ...
}
  • Support accessing nested properties. Example:
    Given
<h1>{{ nested.property }}</h1>

and

const data = {
  nested: {
    property: "Osid's awesome"
  }
}

should resolve in:

<h1>Osid's awesome</h1>
  • Support express through the .__express property. Read more here and here.

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.