Giter Club home page Giter Club logo

Comments (9)

Zulko avatar Zulko commented on May 21, 2024

I'd be ok for it (others, any opinion ?). Exposing require should make it easy for users to extend the framework, but when you multiply the "require" it will make rendering slower (since it requires at every run).

Out of curiosity what is your use-case ?

I think I will also make yaml import easy. I like yaml.

from relaxed.

catc avatar catc commented on May 21, 2024

My current use case is:

  • i run a script, generate some data - let's say it's json
  • my doc.pug imports that data, consumes it, builds the pdf
  • i run the script again to generate other data, build the pdf with new data
  • rinse and repeat

The main benefit would be that you wouldn't have to store your data structures in the pug file, and pug would only contain rendering logic.

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

This much is clear, the question was more what kind of data, how does it get rendered (table ? graph ?) what kind of document, is it for "interactive" use or use on a server, etc. I'm trying to get ideas of how it could get use, it can influence directions of the software.

from relaxed.

catc avatar catc commented on May 21, 2024

It doesn't have to be rendered in any specific way. The whole point is that users could keep their external data in a separate file, import the raw js/json file and render it. This would help keep your pug file clean of any data/variables.

Another huge benefit of adding exposing the require definition to the pug renderer is that you'd have access to other npm modules in the renderer. You could do something like:

- var escape = require('lodash/escape')

p An escaped ampersand looks like: #{escape('&')}

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

Done. See this test example. Note that ReLaXed also exposes path and basedir (the directory where the master pug document is). In the example these two constants are used to resolve the path of the local data.json.

from relaxed.

catc avatar catc commented on May 21, 2024

Looks good! Can you get a new build/version out on npm?

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

possibly this evening

from relaxed.

catc avatar catc commented on May 21, 2024

Thanks!

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

now in version 0.1.6 on npm

from relaxed.

Related Issues (20)

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.