Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a debug tag #247

Closed
seangates opened this issue Mar 11, 2016 · 4 comments
Closed

Create a debug tag #247

seangates opened this issue Mar 11, 2016 · 4 comments
Labels

Comments

@seangates
Copy link
Contributor

<invoke console.log(someData)/>

This is good, but it could be much better. 馃槃

Some thoughts on creating a debugger:

  • Pretty printing to the browser
  • Additional information about the data (object type, length of the data)
  • processing time
  • the template path in which the debugger it's called
  • limiting the debugger to only show in non-prod environments (don't know if this is possible, but ... would be nice)
  • etc.
@mlrawlings mlrawlings added type:feature A feature request scope:core taglib needs more info Original poster needs to provide more information before action can be taken labels Jul 15, 2016
@mlrawlings
Copy link
Member

Do you have any specific use cases in mind? Would something like a Marko DevTools chrome extension be better suited for accomplishing your goals?

@patrick-steele-idem
Copy link
Contributor

Would be nice to have a convention for enabling "Marko Debug Mode". For example, via an environment variable:

DEBUG=marko node server.js

In debug mode, we could add extra information to templates. For example, What if we automatically added a data-template-path attribute to the root HTML element(s) of every compiled template?:

<div data-template-path="/my-project/components/foo/index.marko">
    <h1>Foo</h1>
    <div>
        <div data-template-path="/my-project/components/bar/index.marko">
            <h2>Bar</h2>
        </div>
    </div>
</div>

This information could be helpful to developers, but it could also be used to enable more advanced in-browser development tools.

@patrick-steele-idem patrick-steele-idem added this to the 4.0 milestone Nov 8, 2016
@mlrawlings
Copy link
Member

Comments might provide more info if say, bar includes baz:

<!-- Begin: /my-project/components/foo/index.marko -->
<div>
    <h1>Foo</h1>
    <div>
        <!-- Begin: /my-project/components/bar/index.marko -->
            <!-- Begin: /my-project/components/baz/index.marko -->
                <div>
                    <h2>Baz</h2>
                </div>
            <!-- End: /my-project/components/baz/index.marko -->
        <!-- End: /my-project/components/bar/index.marko -->
    </div>
</div>
<!-- End: /my-project/components/foo/index.marko -->

@Hesulan
Copy link
Contributor

Hesulan commented Nov 12, 2016

I've seen at least a few other major projects add HTML comments like that to their output for various reasons, including debugging. Angular even uses a similar syntax to bind code to the DOM (<!-- ngRepeat: post in posts -->). On the other hand, element attributes might provide some benefits that comments couldn't, especially within the parser/compiler/renderer, as they would be assigned directly to the relevant AST nodes - though the idea of using element attributes (which are usually supposed to affect something) to display debug information (which is never supposed to affect anything) is a bit unnerving.

What about something in-between? Throughout the parsing/compiling/rendering process the debug information could be stored in a property on the relevant AST node - or maybe in a parent node similar to an HtmlComment element, or perhaps even some combination of the two - then eventually rendered as HTML comments like in the example above. Then tools could be written to simply hook into the property/node to extract debug information during the compiling and rendering processes, and there would also be helpful HTML comments in the final output.

Special debugging tags and attributes could also be added, like debug=true to toggle verbose debugging on specific element trees, debug-render-time to track and report how long nodes take to render, and maybe even something like <observe(someData)> to watch an object for changes, just to name a few. If all of this was handled by the special debug property/node, and only when some special flag (like DEBUG=marko or --debug) is detected, I would think this could be implemented without too many side effects. Thoughts?

@mlrawlings mlrawlings modified the milestone: 4.0 Mar 13, 2017
@patrick-steele-idem patrick-steele-idem removed the needs more info Original poster needs to provide more information before action can be taken label Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants