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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump() to console? #58

Open
RobLoach opened this issue Oct 31, 2023 · 0 comments
Open

dump() to console? #58

RobLoach opened this issue Oct 31, 2023 · 0 comments

Comments

@RobLoach
Copy link

RobLoach commented Oct 31, 2023

Was considering making a dump() implementation that would output to the console. While dump() is adequite for simple debugging, leverage the console could speed up development...

Twig.extendFunction('vardumper', function(...args) {
  if (args.length === 0) {
    console.log(Twig.functions.dump(this.context))
  }
  else {
    console.log(Twig.functions.dump(...args))
  }
});

Another option is to output directly to the browser's console too...

let output = Twig.functions.dump(this.context);
return '<script>console.log(' + output + ');</script>';

console.dir() could be a good alternative to something like kint: https://developer.mozilla.org/en-US/docs/Web/API/console/dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant