Giter VIP home page Giter VIP logo

Comments (5)

PaulHuizer avatar PaulHuizer commented on July 16, 2024

This is indeed something I required as well. My usecase is to skipping debug info for the production version, while I would include the debug info in my debug version.

I made small modifications to the bake.js file to make this available:

Modification 1:

        function inlineReplace( attributes, content, filePath, values ) {
            var inlineValues = parseInlineValues( attributes );
            if ( doSkip(inlineValues)) return ""; // <-- Added this line
            if ( validateIf( inlineValues, values ) ) return "";

modification 2: added the doSkip function underneath the validateIf function:

        // Handle _skip attributes in inline arguments
        function doSkip(inlineValues) {
            if ("_skip" in inlineValues) {
                var skipValue = inlineValues["_skip"];
                var taskOptions = grunt.task.current.data.options;
                if (skipValue in taskOptions) {
                    var doSkip = taskOptions[skipValue];
                    console.log("Skip value "+skipValue+" result is: "+doSkip);
                    return doSkip;
                }
                else
                    console.log("Skip value "+skipValue+" not found on task Options.");
            }
            console.log("Leave validateSkip with false");
            return false;
        }

This enables the following syntax:

    <!--(bake-start _skip="exludeDebug")-->
.. anything you like here ...
    <!--(bake-end)-->

in the gruntfile:

bake:{
yourTarget:{
        options: {
            excludeDebug: (configuration != "debug"),
        },
        files: ...
}

Using a flag in the options section of the bake target, you can control whether content will be skipped or not.

Feel free to use it, feedback on it, modify it or get inspired by it.

from grunt-bake.

roboshoes avatar roboshoes commented on July 16, 2024

Pretty much what @PaulHuizer describes here was implemented by us as the _render attribute. See here: https://github.com/MathiasPaumgarten/grunt-bake/#inline-_render-statement

Does that solve your problem/feature-request?

from grunt-bake.

ffraval avatar ffraval commented on July 16, 2024

Hi,

i'm afraid it's not.

The idea is that bake knows when an html file is baked as an html file or is included in an another html file in the same task run. My idea is to have access to this internal knowledge to decide if a html portion has to be removed or not.

Perhaps i'm wrong but relying on a user task's setting doesn't provide this.

By the way, here's what we've done with your great tool. Thanks a lot because we couldn't have done this in 4 month without bake :).

http://www.rtl.fr/replay

from grunt-bake.

PaulHuizer avatar PaulHuizer commented on July 16, 2024

for me it works fine!!!

from grunt-bake.

roboshoes avatar roboshoes commented on July 16, 2024

As I am reviewing some older issues. This has been open for a long time and not approved upon. I think I will close this feature task until it comes up again. I haven't heard of another person needing it.

Thanks everyone! If anyone is still in need for this, I am more than willing to revisit this.

from grunt-bake.

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.