GithubHelp home page GithubHelp logo

Comments (6)

philidem avatar philidem commented on May 7, 2024

From looking at the code it does look like the taglib loading relies on a path to json file. I'll investigate making changes to allow loading a taglib from object in memory.

from marko.

rdner avatar rdner commented on May 7, 2024

Thank you, @philidem!
Looking forward to use this feature in my project.

from marko.

patrick-steele-idem avatar patrick-steele-idem commented on May 7, 2024

Just to elaborate on @philidem comments (and this may be more information than you need), we only want to support declarative registration of custom tags for the following reasons:

  1. Tags need to be discovered at compile time (the templates compile differently based on the set of known tags) and the tags need to be available at runtime (which may be on the server or the client) and it would be awkward to have to register custom tags in both places.
  2. The markoc command line compiler should to be able to compile templates without running any user JS code (that is tags need to be discovered based on a declarative mechanism)
  3. There is no single lookup for all tags and custom tags are discovered relative to a template's location on disk. Among other things, this allows installed modules to have their own custom tags that would not pollute the parent application.
  4. Templates are compiled such that custom tag renderers are require'd and this allows client-side JavaScript module bundlers to automatically include only the tags that are needed by a compiled template module

I can't think of any reason that you would need to programmatically register new tags at runtime, but if you share more details about your use case then maybe I can offer better help.

Thanks for the feedback. Let us know if you have any more questions.

from marko.

patrick-steele-idem avatar patrick-steele-idem commented on May 7, 2024

Also, if you have ideas on how we can improve how tags are registered then please feel free to share, but there is a requirement that it needs to be declarative (for the reasons above).

from marko.

philidem avatar philidem commented on May 7, 2024

I did investigate this and I came to the same conclusion as Patrick. I think it would have technically been possible to support the definition of tags through a code change but this goes in the opposite direction of modularizing tags and the components that use them. The discovery mechanism for finding tags is an important feature of Marko that allows tags/components to be shared without having to require users to manually register tags. For this reason, I would discourage manually registering tags and instead rely on the discovery of tags from marko-taglib.json and marko-tag.json files. I would also like to know if relying on these files prevents your project from using Marko effectively.

from marko.

rdner avatar rdner commented on May 7, 2024

I agree with you, this is right decision in this case.

But in my situation I need to integrate Marko into my framework. It means I need to register some module-wrappers as custom tags and it is needed to do before calling compile method.

Actually, this is not a big problem for me because I have simplified stream-based HTML parser for using these module-wrappers as custom tags. I just wanted to remove my implementation and replace it with Marko functionality.

Thank you, anyway.

from marko.

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.