html asset ref
ryanburnette opened this issue · comments
I have come up with the idea of using an htmlassetref package. The job of this package is to receive html as well as a handler cb func. It finds all asset refs, to which I have written some example html which can be modified to help maintain this package and its test. The cb func should get the html, something like <link rel="stylesheet" href="style.css">
, and the ref style.css
and allow you to update the ref, returning the new value which will be updated.
My initial approach was to use regex, but that might be too hard to maintain.
I could go for a third party lib like goquery.
All this makes the library more fragile if the html is invalid.
I could just look for the filenames themselves, but I'm not sure if that's enough context.
Need some input.
Is it a virtue of Go that I keep ending up with my working code simpler than my early failed attmpts? https://github.com/ryanburnette/go-hash-assets/blob/fc3c6d3904345e3df4f8232c10d1cf2c88fc7975/htmlassetref/htmlassetref.go