FANDOM


  • I've got a pretty minor template problem, and have found a fairly decent workaround, but am wondering if I'm missing some more obvious or better solution.

    When making a wikitable, it's usually no problem to have a cell that consists of just a list of items, like

    {|border="1" class="wikitable"
    |-
    |
    *List item 1
    *List item 2
    |}

    But if I try to make a template for that simple table,

    {|border="1" class="wikitable"
    |-
    |{{{cellcontent}}}
    |}

    and then use it like

    {{Sandbox/TableTest
    |cellcontent = 
    *List item 1
    *List item 2
    }}

    It doesn't display properly, I believe because the beginning whitespace is being ignored. I could force the newline into the template, except that would mess things up for any cell content that doesn't start with a list.

    The best workaround I've found is this

    {{Sandbox/TableTest
    |cellcontent = <b></b>
    *List item 1
    *List item 2
    }}

    Since it forces the newline to be kept but doesn't actually have anything in the first line to display, it doesn't add any extra size to the cell. But still, anything that must be done on many actual uses of the template is pretty suboptimal.

    I just tried a different solution where the template would check to see if the first character of cellcontent was a *, in which case it would add a newline on the template side. However, this didn't work--anything successfully added by the check was still followed by the first list item not displaying as a list item.

    {|border="1" class="wikitable"
    |-
    |{{#ifeq:{{#sub:{{{cellcontent}}}|0|1}}|*|test1<b></b>
    <b></b>}}{{{cellcontent}}}
    |}
      Loading editor
    • link would be much better.

      try to use
      {|
      |-
      ||cellcontent
        Loading editor
    • I place the variable on the next line as your 1st prebox

      {|border="1" class="wikitable"
      |-
      |
      *List item 1
      *List item 2
      |}
      

      becomes

      {|border="1" class="wikitable"
      |-
      |
      {{{cellcontent}}}
      |}
      
        Loading editor
    • 20191006regularvstemplate
      Fngplg, what you suggest I didn't notice a change with. TableWiz, what you suggested is something I tried before but didn't like as a solution because it adds extra empty vertical space to things that don't start as a list.
        Loading editor
    • 20191006regularvstemplate2
      Well, I got it working. It seemed crazy that trying to get a simple newline to show up on command would be a problem--if I can make a table without and one with, then at the extreme how about a check that creates totally different tables, one with and one without? I didn't go that far, but I guess broadening it just a little bit made it work as intended.
      {|border="1" class="wikitable"
      {{#ifeq:{{#sub:{{{cellcontent}}}|0|1}}|*|
      {{!}}-
      {{!}}
      {{{cellcontent}}}|
      {{!}}-
      {{!}}{{{cellcontent}}}}}
      |}
        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.