{"size": 697, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "vitkarpov/tiny-bemjson", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "vitkarpov/tiny-bemjson", "max_issues_repo_issues_event_min_datetime": "2020-09-06T14:26:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T19:35:20.000Z", "max_forks_repo_path": "index.js", "max_forks_repo_name": "vitkarpov/tiny-bemjson", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 19.9142857143, "max_line_length": 59, "alphanum_fraction": 0.5767575323}
const classname = require("./lib/classname");
const serializeAttrs = require("./lib/serialize-attrs");

function render(bemjson) {
  if (typeof bemjson === "string") {
    return bemjson;
  }
  if (Array.isArray(bemjson)) {
    return bemjson.map(render);
  }

  const tag = bemjson.tag || "div";
  const className = [classname(bemjson), bemjson.cls || ""]
    .filter(Boolean)
    .concat((bemjson.mix || []).map(classname))
    .join(" ");
  const attrs = serializeAttrs(
    Object.assign({ class: className }, bemjson.attrs)
  );

  return [
    "<",
    tag,
    " ",
    attrs,
    ">",
    render(bemjson.content || ""),
    "</",
    tag,
    ">"
  ].join("");
}

module.exports = render;
