Skip to content

a quick & dirty helper to render any record type to the DOM, for debugging purposes.

License

Notifications You must be signed in to change notification settings

aslakg/elm-print-any

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-print-any

A quick & dirty helper to render any record type to the DOM, for debugging purposes.

When you are dealing with large models or large records, with many fields of different shapes, you sometimes want to be able to inspect that model. Then the straightforward Debug.log "my model" model to print the model to the console will give you a "minified" and unreadable version of your model. Especially if there are lists in it.

The helper view function in this tiny library will print any record type to your DOM. Anywhere in your view function, you can do:

view model =
	div []
		[ ...
		, PrintAny.view model
		]

The output is a <div> with a list of indented <p> paragraphs in it.

The helper log prints a somewhat prettified version of the record to the console. It works similar to Debug.log Usage is as follows:

myNewRecord = PrintAny.log myRecord

Typical use case would be: your app renders a view that is different from what you expected. And you want to inspect the contents of your model at the time of rendering.

Both functions help you do just that.

If your record is really large, rendering will be slow.

About

a quick & dirty helper to render any record type to the DOM, for debugging purposes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elm 100.0%