You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main purpose of this repository is to make the job easier for theme developers in transforming the resume object to suit their theme needs. The current implementation is pretty ad-hoc since all I did was just transfer this repository to jsonresume & I did not have a proper plan back then. So, the code in this repo is highly contextual to elegant's need. I want this to be generic so that any theme developer can use it to their benefits.
Following are the computations most theme developers do
get the picture from gravatar using the specified email address if the user fails to provide a url
formatting dates
computing the resume.basics.location object
computing the url for a profile based on the profile.username & profile.network
markdown to html conversion
I thought about how the api should look & here's what I propose. The theme developers pass the resume object to utils.transformResume method which would emit out the transformed resume object which they can directly plug into the template, this method would take resume as first argument & options as second argument. So, in a nutshell the code to render a theme would look as follows:
varutils=require('jsonresume-themeutils');functionrender(resume){resume=utils.transformResume(resume,options);// return the compiled html}module.exports={render: render};
The options object structure will be similar to jsonresume schema, the keys remain the same but the value will be replaced with a transformer function which takes the input as resume[key], does the transformation & returns a value(If this sentence was confusing, I hope it'll be easier with an example below)
varutils=require('jsonresume-themeutils');varmarked=require('marked');functionmarkdownTransformer(str){returnmarked(str);}functionpictureTransformer(url,email){if(url!=null){returnurl;}// get url from gravatar}functionaddressTransformer(location){return[location.city,location.state,location.country].join(', ');}functionprofileTransformer(profile){if(profile.url){returnprofile.url;}// compute url using profile.network & profile.username}functionrender(resume){varoptions={basics: {summary: markdownTransformer,// equivalent to, resume.basics.summary = markdownTranformer(resume.basics.summary) & so on...location: addressTransformer,picture: pictureTransformer},profiles: [profileTransformer],//if the transformer is specified inside an array, it'll be run against each item in the array else it'll run on the complete array.work: [{startDate: dateTransformer,summary: markdownTransformer}]};resume=utils.transformResume(resume,options);// return compiled html}module.exports={render: render}
We can move common transformers such as profileTransformer, pictureTransformer etc under this repo so that developers can directly use utils.profilerTransformer so that they can reuse the logic. Thoughts?
The text was updated successfully, but these errors were encountered:
The main purpose of this repository is to make the job easier for theme developers in transforming the resume object to suit their theme needs. The current implementation is pretty ad-hoc since all I did was just transfer this repository to jsonresume & I did not have a proper plan back then. So, the code in this repo is highly contextual to elegant's need. I want this to be generic so that any theme developer can use it to their benefits.
Following are the computations most theme developers do
resume.basics.location
objectprofile.username
&profile.network
I thought about how the api should look & here's what I propose. The theme developers pass the
resume
object toutils.transformResume
method which would emit out the transformedresume
object which they can directly plug into the template, this method would takeresume
as first argument &options
as second argument. So, in a nutshell the code to render a theme would look as follows:The
options
object structure will be similar to jsonresumeschema
, the keys remain the same but the value will be replaced with a transformer function which takes the input asresume[key]
, does the transformation & returns a value(If this sentence was confusing, I hope it'll be easier with an example below)We can move common transformers such as
profileTransformer
,pictureTransformer
etc under this repo so that developers can directly useutils.profilerTransformer
so that they can reuse the logic. Thoughts?The text was updated successfully, but these errors were encountered: