{% comment %} # ----------------------------------------------------------------------------- # ~/_includes/themes/j1/procedures/layouts/module_writer.proc # Liquid PROCEDURE to write|place the HTML markup for Javascript init # scripts defined for a layout # # Product/Info: # https://jekyll-one.com # # Copyright (C) 2019 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one/j1_template_mde/blob/master/LICENSE # # ----------------------------------------------------------------------------- # Test data: # liquid_var: {{ liquid_var | debug }} # # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Liquid procedures --------------------------------------------------------------- {% endcomment %} {% capture collect_module_defaults %}themes/{{site.template.name}}/procedures/layouts/collect_module_defaults.proc{% endcapture %} {% capture collect_frontmatter_options %}themes/{{site.template.name}}/procedures/global/collect_frontmatter_options.proc{% endcapture %} {% comment %} Variables --------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign logger_config = site.data.modules.j1_log4javascript %} {% assign loader_finished_message = logger_config.loader_finished_message %} {% assign items = include.resources %} {% assign placement = include.region %} {% comment %} For default, init parameters passed to adapters ------------------------------------------------------------- {% endcomment %} {% assign pass_init_data = true %} {% comment %} Main --------------------------------------------------------------- {% endcomment %} {% for resources in items %} {% for resource in resources %} {% for parameters in resource %} {% for parameter in parameters %} {% assign data_type = parameter | is_type %} {% if data_type == 'array' %} {% assign key = parameter[0] %} {% assign value = parameter[1] %} {% if key == 'enabled' %} {% assign enabled = value %} {% endif %} {% if key == 'id' %} {% assign id = value %} {% endif %} {% if key == 'comment' %} {% assign comment = value %} {% endif %} {% if key == 'layout' %} {% assign layouts = value %} {% endif %} {% if key == 'required' %} {% assign required = value %} {% endif %} {% if key == 'pass_init_data' %} {% assign pass_init_data = value %} {% endif %} {% if key == 'data' %} {% assign data = value %} {% endif %} {% endif %} {% endfor %} {% endfor %} {% if enabled and placement == 'body-footer' %} {% comment %} NOTE: Module default values collected by J1 Adapter ------------------------------------------------------- {% endcomment %} {% comment %} Collect Frontmatter options (page) ------------------------------------------------------- {% endcomment %} {% include {{collect_frontmatter_options}} module=id %} {% assign frontmatter_options = {{frontmatter_options}} %} {% assign layout_valid = false %} {% for layout in layouts %} {% assign layout = layout | downcase %} {% if layout == page.layout or layout == "all" %} {% assign layout_valid = true %} {% endif %} {% endfor %} {% assign resource_valid = false %} {% if required == 'always' %} {% assign resource_valid = true %} {% else %} {% for resource in page.resources %} {% if resource == id %} {% assign resource_valid = true %} {% endif %} {% endfor %} {% endif %} {% if layout_valid and resource_valid %} {% for data_var in data %} {% assign data_key = data_var[0] %} {% assign data_value = data_var[1] %} {% if data_key == 'init_function' %} {% endif %} {% endfor %} {% endif %} {% endif %} {% endfor %} {% endfor %}