Page MenuHomePhabricator

Decide on what to recommend for table style usecase
Open, LowPublic

Description

The guidance we give for TemplateStyles is to assume that the CSS won't apply outside of the template which contains the <templatestyle> tag (although this cannot be technically enforced yet). See e.g. caveats, item 3.

This is at odds with an important use case: styling article content, especially templates, which tend to involve repetitive inline styles and can look quite monstrous (see this table as a random example). Since the content comes from the article itself and not a template, there isn't really any way to apply CSS to the table while keeping it inside the DOM node(s) of the template. One could use a wrapper template:

{{wrapper|content=

...lots of wikitext here...

}}

but that will break VisualEditor which cannot visually edit template parameters; and turns | into {{!}} in the wrapped wikitext, which is a nightmare for large tables.

In the long term, heredoc template syntax (T114432) might be the solution; for now, we need to decide what guidance to give on current usage patterns of TemplateStyles. Tables in articles are an important use case and we shouldn't discourage people from fixing it, but we also do not want for everyone to fix it differently, and probably want to track such out-of-template-scope usages in some way.

Event Timeline

Tgr created this task.Sep 19 2017, 9:53 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 19 2017, 9:53 PM
Anomie moved this task from Up next to Non-code on the TemplateStyles board.Sep 19 2017, 10:20 PM
He7d3r added a subscriber: He7d3r.Dec 29 2017, 11:47 AM
ggellerman moved this task from Non-code to Up next on the TemplateStyles board.Mar 1 2018, 5:48 PM
Deskana triaged this task as Low priority.Apr 11 2018, 12:50 PM
Deskana added a subscriber: Deskana.

This is not an immediate priority for the initial deployment of TemplateStyles.

Izno added a subscriber: Izno.EditedAug 5 2018, 6:17 PM

I have made a few edits to try cleaning up a table to see who has heartburn. Feedback is welcome here or on-wiki.

Tgr added a comment.Aug 5 2018, 7:35 PM

Putting the template with the styles after the table might result in a FOUC (although not a huge deal as long as it's just colors and no layout-related rules).

Moving my comment from the dupliacte here :

Currently on English Wikipedia, there are a number of tables which use inline CSS formatting to achieve certain effects such as alignment of text, or specfic bordering styles.. Mediawiki as configured on English Wikipedia provides a 'wikitable' class which provides a nice looking set of styling for some tables.

However, by comparison English Wikisource currently provides a table style template: https://en.wikisource.org/wiki/Template:Table_style which provides a number of short code sequences (currently upto 9) to apply various forms of table formatting. The current implementation of this template is a directly coded MASSIVE parser function, which to add new codes requires that the /parse portion of the template be updated directly, and has performance implications..

A better way of doing this to me would be to have an equivalent of TemplateStyles for Tables, allowing relevant styles to be applied on a per table basis, albiet the stylesheet(s) for a given sequence of tables may be the same stylesheet page located elsewhere on a given wiki.

The TableStyle template itself could then be altered so that the short codes are converted into name munged class names in a common CSS defined style sheet, such that new codes could be easily added to the style sheet, without needing to alter the core logic of the TableStyle template itself...

Also Could TemplateStyles could be used on certain non-template WikiPages, where a commonality of styling without using inline CSS would be desirable?

Izno moved this task from Up next to Non-code on the TemplateStyles board.Sep 28 2018, 1:46 PM