Skip to content

Pretty print #2075

@nazar-pc

Description

@nazar-pc

According to what I found here in issues there was at least few people who suffer from this, but issue was not resolved.
I have following piece of Jade:

dom-module(id="cs-system-admin-components-modules-list")
    link(rel="import" href="style.css" type="css")
    template
        style(include="advanced-styles")
        table.cs-table(center list)
            tr
                th [[L.module_name]]
                th [[L.state]]
                th [[L.action]]
            template(is="dom-repeat" items="[[modules]]" as="module")
                tr(class$="[[module.class]]")
                    td
                        a(href="[[concat('/admin/', module.name)]]" tooltip="[[module.info]]" hidden$="[[!module.administration]]")
                            span [[module.name_localized]]
                            cs-tooltip
                        span(tooltip="[[module.info]]" hidden$="[[module.administration]]")
                            span [[module.name_localized]]
                            cs-tooltip
                    td
                        cs-icon(icon="[[module.icon]]" tooltip="[[module.icon_text]]")
                        template(is="dom-if" if="[[module.api]]")
                            cs-icon(icon="link" tooltip="[[L.api_exists]]" hidden$="[[module.api.type]]")
                            button(is="cs-button" type="button" icon="link" tooltip="[[concat(L.api_exists, '<br>', L.click_to_view_details)]]" hidden$="[[!module.api.type]]")
                            section(is="cs-section-modal" content="[[module.api.content]]")
                        button(is="cs-button" type="button" icon="book" tooltip="[[concat(L.information_about_module, '<br>', L.click_to_view_details)]]" hidden$="[[!module.readme]]")
                        section(is="cs-section-modal" content="[[module.readme.content]]")
                        button(is="cs-button" type="button" icon="legal" tooltip="[[concat(L.license, '<br>', L.click_to_view_details)]]" hidden$="[[!module.license]]")
                        section(is="cs-section-modal" content="[[module.license.content]]")
                    td(left)
                        a(is="cs-link-button" icon="home" href="[[concat('/admin/System/components/modules/default_module/', module.name)]]" tooltip="[[L.make_default_module]]" hidden$="[[!module.can_be_set_as_default]]")
                        a(is="cs-link-button" icon="database" href="[[concat('/admin/System/components/modules/db/', module.name)]]" tooltip="[[L.databases]]" hidden$="[[!module.db_settings]]")
                        a(is="cs-link-button" icon="hdd-o" href="[[concat('/admin/System/components/modules/storage/', module.name)]]" tooltip="[[L.storages]]" hidden$="[[!module.storage_settings]]")
                        a(is="cs-link-button" icon="sliders" href="[[concat('/admin/', module.name)]]" tooltip="[[L.module_admin_page]]" hidden$="[[!module.administration]]")
                        a(is="cs-link-button" icon="minus" href="[[concat('/admin/System/components/modules/disable/', module.name)]]" tooltip="[[L.disable]]" hidden$="[[!equal(module.active, 1)]]")
                        a(is="cs-link-button" icon="check" href="[[concat('/admin/System/components/modules/enable/', module.name)]]" tooltip="[[L.enable]]" force-compact hidden$="[[!equal(module.active, 0)]]") [[L.enable]]
                        a(is="cs-link-button" icon="trash" href="[[concat('/admin/System/components/modules/uninstall/', module.name)]]" tooltip="[[L.uninstall]]" hidden$="[[equal(module.active, -1)]]")
                        a(is="cs-link-button" icon="download" href="[[concat('/admin/System/components/modules/install/', module.name)]]" tooltip="[[L.install]]" force-compact hidden$="[[!equal(module.active, -1)]]") [[L.install]]
    script(src="script.js")

Eventually with pertty print it becomes this:

<dom-module id="cs-system-admin-components-modules-list">
  <link rel="import" href="style.css" type="css">
  <template>
    <style include="advanced-styles"></style>
    <table center list class="cs-table">
      <tr>
        <th>[[L.module_name]]</th>
        <th>[[L.state]]</th>
        <th>[[L.action]]</th>
      </tr>
      <template is="dom-repeat" items="[[modules]]" as="module">
        <tr class$="[[module.class]]">
          <td><a href="[[concat('/admin/', module.name)]]" tooltip="[[module.info]]" hidden$="[[!module.administration]]"><span>[[module.name_localized]]</span>
              <cs-tooltip></cs-tooltip></a><span tooltip="[[module.info]]" hidden$="[[module.administration]]"><span>[[module.name_localized]]</span>
              <cs-tooltip></cs-tooltip></span></td>
          <td>
            <cs-icon icon="[[module.icon]]" tooltip="[[module.icon_text]]"></cs-icon>
            <template is="dom-if" if="[[module.api]]">
              <cs-icon icon="link" tooltip="[[L.api_exists]]" hidden$="[[module.api.type]]"></cs-icon>
              <button is="cs-button" type="button" icon="link" tooltip="[[concat(L.api_exists, '&lt;br&gt;', L.click_to_view_details)]]" hidden$="[[!module.api.type]]"></button>
              <section is="cs-section-modal" content="[[module.api.content]]"></section>
            </template>
            <button is="cs-button" type="button" icon="book" tooltip="[[concat(L.information_about_module, '&lt;br&gt;', L.click_to_view_details)]]" hidden$="[[!module.readme]]"></button>
            <section is="cs-section-modal" content="[[module.readme.content]]"></section>
            <button is="cs-button" type="button" icon="legal" tooltip="[[concat(L.license, '&lt;br&gt;', L.click_to_view_details)]]" hidden$="[[!module.license]]"></button>
            <section is="cs-section-modal" content="[[module.license.content]]"></section>
          </td>
          <td left><a is="cs-link-button" icon="home" href="[[concat('/admin/System/components/modules/default_module/', module.name)]]" tooltip="[[L.make_default_module]]" hidden$="[[!module.can_be_set_as_default]]"></a><a is="cs-link-button" icon="database" href="[[concat('/admin/System/components/modules/db/', module.name)]]" tooltip="[[L.databases]]" hidden$="[[!module.db_settings]]"></a><a is="cs-link-button" icon="hdd-o" href="[[concat('/admin/System/components/modules/storage/', module.name)]]" tooltip="[[L.storages]]" hidden$="[[!module.storage_settings]]"></a><a is="cs-link-button" icon="sliders" href="[[concat('/admin/', module.name)]]" tooltip="[[L.module_admin_page]]" hidden$="[[!module.administration]]"></a><a is="cs-link-button" icon="minus" href="[[concat('/admin/System/components/modules/disable/', module.name)]]" tooltip="[[L.disable]]" hidden$="[[!equal(module.active, 1)]]"></a><a is="cs-link-button" icon="check" href="[[concat('/admin/System/components/modules/enable/', module.name)]]" tooltip="[[L.enable]]" force-compact hidden$="[[!equal(module.active, 0)]]">[[L.enable]]</a><a is="cs-link-button" icon="trash" href="[[concat('/admin/System/components/modules/uninstall/', module.name)]]" tooltip="[[L.uninstall]]" hidden$="[[equal(module.active, -1)]]"></a><a is="cs-link-button" icon="download" href="[[concat('/admin/System/components/modules/install/', module.name)]]" tooltip="[[L.install]]" force-compact hidden$="[[!equal(module.active, -1)]]">[[L.install]]</a></td>
        </tr>
      </template>
    </table>
  </template>
  <script src="script.js"></script>
</dom-module>

Yes, there is one empty line from the beginning, which doesn't bother me that much, what really makes me crazy is that in some random places new lines are present, but in others not.

Don't even try to tell me that I should use stylesheet to separate 2 links in order to avoid them look as single word. I understand that sometimes it might be useful, but I suppose in most cases people just got frustrated, it should work as in regular HTML out of the box. It might not be aligned, but single new line character doesn't cost anything significant.

Some option to just preserve new lines would be awesome (since you're planning to drop pretty print from core). I'm migrating from HAML, and it was so natural....

I saw #905 and #1834 and really hope that this issue will get higher priority.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions