Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table render hook: add Inner method #13469

Open
jmooring opened this issue Mar 3, 2025 · 1 comment
Open

table render hook: add Inner method #13469

jmooring opened this issue Mar 3, 2025 · 1 comment

Comments

@jmooring
Copy link
Member

jmooring commented Mar 3, 2025

Currently, if all you want to do is wrap a table with a div, you have to do this:

<div class="overflow-x-auto">
  <table
    {{- range $k, $v := .Attributes }}
      {{- if $v }}
        {{- printf " %s=%q" $k $v | safeHTMLAttr }}
      {{- end }}
    {{- end }}>
    <thead>
      {{- range .THead }}
        <tr>
          {{- range . }}
            <th
              {{- with .Alignment }}
                {{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
              {{- end -}}
            >
              {{- .Text -}}
            </th>
          {{- end }}
        </tr>
      {{- end }}
    </thead>
    <tbody>
      {{- range .TBody }}
        <tr>
          {{- range . }}
            <td
              {{- with .Alignment }}
                {{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
              {{- end -}}
            >
              {{- .Text -}}
            </td>
          {{- end }}
        </tr>
      {{- end }}
    </tbody>
  </table>
</div>

It would be convenient if we could do this instead:

<div class="overflow-x-auto">
  {{ .Inner }}
</div>
@jmooring
Copy link
Member Author

jmooring commented Mar 3, 2025

I wrote this while thinking about a render hook for the docs site, but when I actually implemented it I realized that I wanted to replace the inline alignment styles with classes, so I wouldn't have used .Inner anyway.

So... this should have a very low priority. No one else has ever asked for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants