GithubHelp home page GithubHelp logo

Comments (3)

douglatornell avatar douglatornell commented on June 30, 2024

So, this is really a blogofile issue, not a blogofile_blog one, correct? Though, of course, you need a site, which comes from a plugin like blogofile_blog, to demonstrate the issue.

from blogofile_blog.

brandon-rhodes avatar brandon-rhodes commented on June 30, 2024

Yes, the issue is with the function itself in blogofile/util.py — either we could add a clause to it like the one it already has for assuring that the links it generates are preceded with slashes that also checks for a terminal slash, or we could add the clause behind a test for a new option "append_slash_to_site_paths" or something so that people would have to make a deliberate change to get the new behavior. (And thanks, by the way, for taking over blogofile — it has been great to watch all the activity on github each time I log in, because of your work!)

from blogofile_blog.

douglatornell avatar douglatornell commented on June 30, 2024

So, just adding a trailing slash would break this use case:

<script src="${bf.util.site_path_helper('js/libs/modernizr-1.7.min.js')}"></script>

That breakage could be avoided by checking for a file extension at the end of the path and only adding the trailing slash if there wasn't one, but that feels like it could be fraught with other exceptions.

Add to the above that "explicit is better than implicit" and we arrive at a new function signature:

site_path_helper(*parts, trailing_slash=False)

It turns out that a signature like that is valid in Python 3, but not in Python 2. Who knew? Certainly not me. To suppport both version the signature has to be:

site_path_helper(*parts, **kwargs)

and the function has to do the kwargs-processing dance.

This may be the first time I've hit one of the syntactic improvements in Python 3 that has really made me regret having to support Python 2 as well. The Python 3 version is just plain clearer and more elegant. Fodder for your code beauty talk?

from blogofile_blog.

Related Issues (16)

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.