HackMyResume icon indicating copy to clipboard operation
HackMyResume copied to clipboard

Suggestions for better way to pass parameter to theme?

Open aruberto opened this issue 9 years ago • 2 comments

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?

aruberto avatar Jan 10 '16 23:01 aruberto

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!

hacksalot avatar Jan 11 '16 00:01 hacksalot

Did you ever end up going ahead with this @aruberto?

hacksalot avatar Jan 29 '16 22:01 hacksalot