Giter VIP home page Giter VIP logo

Comments (8)

adrinux avatar adrinux commented on July 18, 2024

I can't comment on the specifics (I just don't have that great an understanding) but I have developed a feeling that Punch's content processing is a bit limited and simplistic. Being able to stack handlers would help. As would being able to run helpers on content before handlers, rather than just in templates.

Most of the issues can be got around by writing custom content handlers but those are harder to re-use on different projects and you can't share with the wider community so easily.

from punch.

laktek avatar laktek commented on July 18, 2024

The recommended way to have multiple content handlers is by using the delegation pattern. If you look at the blog-content-handler's code it's implemented this way (by delegating to default content handler when it cannot handle something).

I will write a better tutorial to make this more clear.

@adrinux I'm considering on the idea of making helpers accessible from content handler. Will do some experimentation on that.

from punch.

naholyr avatar naholyr commented on July 18, 2024

Delegation can't be enough, it prevents building efficient third party content handlers. Let's take an example:

  • I've built a content handler generating RSS, working as an overlay to punch-blog-content-handler.
  • I plan building something similar to handle comments (one that will extend content returned by getPosts for example).
  • What if I want to use them both on same time? No way else than editing one of them to delegate to the other instead of delegating to blog-content-handler :( Same applies each time I will want to use two third-party content handlers.

Maybe we could address this issue by providing a helper or snippet to allow configuring delegation (I could say in config.json that I want comments-content-handler to delegate to rss-content-handler instead of directly blog-content-handler, and it would be enough). But in the end, it will the same than providing an ordered list of handlers instead of a single one ;)

Well, actually I'll make my RSS generator a generator_hook, but the need still is here in my opinion. That's why I was wondering if there was a true limit or if there was some space for extra work ;)

from punch.

laktek avatar laktek commented on July 18, 2024

I guess what we need here is a routes-content-handler which can sit on the top and do the delegation based on the URL paths.

I'll try to make it to work during the weekend.

from punch.

naholyr avatar naholyr commented on July 18, 2024

Oh yeah that could do the trick very nicely, perfect idea! Keep in touch :)

from punch.

frankct310 avatar frankct310 commented on July 18, 2024

Just as another use for the content handler: I'm currently working on a content handler that, given a picasa album name in the original json expands that json by including urls to the images in that album. I can do this with the current delegation, however I don't think a routes-content-handler will help me here. Or should I be doing this in a completely different way?

from punch.

naholyr avatar naholyr commented on July 18, 2024

Why can't delegation work here ? Your negotiateContent calls the original
one, expands content, and run callback. Won't it work ? I agree though that
I'm not fond of this principle because the notion of "base content handler"
is very project-specific and if you want to share your plugin you will have
to let user be able to configure it (dependance injection or module's name
in configuration).
Le 11 févr. 2013 23:53, "frankct310" [email protected] a écrit :

Just as another use for the content handler: I'm currently working on a
content handler that, given a picasa album name in the original json
expands that json by including urls to the images in that album. I can do
this with the current delegation, however I don't think a
routes-content-handler will help me here. Or should I be doing this in a
completely different way?


Reply to this email directly or view it on GitHubhttps://github.com//issues/63#issuecomment-13408280.

from punch.

frankct310 avatar frankct310 commented on July 18, 2024

Content delegation does work, but the routes-content-handler will not. I was hoping to provide some more input here with other use cases. Thanks for the input, though!

from punch.

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.