HackMyResume
HackMyResume copied to clipboard
Suggestions for better way to pass parameter to theme?
I've been playing around creating my own theme - https://github.com/aruberto/fresh-theme-bootstrap
I am currently hijacking the css flag to toggle between different swatches like so:
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/{{opts.css}}/bootstrap.min.css" rel="stylesheet"></link>
Seems like kind of hack, any suggestions on a better way to accomplish this?
Nice. You're basically using the css
flag as a theme parameter and this usage is compatible with what HRM will support in 1.6.0.
Instead of bottlenecking stuff through the --css
parameter as you're doing now, you'll be able to pass arbitrary data to the theme (such as a swatch name, font, image, or other arbitrary piece of data) via the HackMy command line or, for more complex data, via the .hackmyrc
or --opts
.
The latter may already work (not sure exactly where the code is on your version) but it's not been formalized or advertised yet. But the idea is, whatever is in your .hackmyrc
or --opts
options file gets mixed in to the runtime model passed to the theme. So your .hackmyrc
could have:
{
"swatch": "cerulean",
"someObject": {
"font": "Helvetica",
"other": "Something else"
}
}
Or equivalently, via command line:
hackmyresume --opts "<embedded json>"
Or:
hackmyresume build resume.json ---swatch cerulean ---someObject.font Helvetica
(Note the triple dash ---
to indicate a pathed theme parameter.) The theme could access them with:
{{ swatch }}
{{ someObject.font }}
Let me know if there are any specific helpers or passthrough functionality you'd like to see in addition and whether you'd like to bundle your theme with HMR when it's ready. Great work!
Did you ever end up going ahead with this @aruberto?