Page MenuHomePhabricator

Consolidate server and client templates
Closed, DeclinedPublic

Description

Server and client implementations must often render similar views. In some places, nearly identical views are generated from distinct Hogan.js and Mustache templates. This task involves reviewing the server and client template usage in MobileFrontend, identifying server and client pairs, and publishing tasks to consolidate each pair. The tasks can be grouped or made distinct per pair depending on complexity and detail uncovered.

Where possible, said tasks should rename Hogan.js and Mustache file extensions to the implementation type, .mustache.

Where server and client deviation is needed, create tasks to separate client view creation from server view parsing and modeling to make view responsibilities distinct. For example, if watchstar.mustache rendered by the server needs to be parsed and modeled by the client for it to render an infinitely scrolling list of watchstars, a WatchstarParser and Watchstar (model) should be separated to distinct module files.

Acceptance criteria

  • A table of template pairs is published on this task's description along with any task to consolidate them

Event Timeline

Restricted Application changed the subtype of this task from "Deadline" to "Task". · View Herald TranscriptNov 30 2018, 6:19 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Niedzielski updated the task description. (Show Details)Nov 30 2018, 6:28 PM
Jdlrobson added a subscriber: Jdlrobson.

We're planning to look at this around Jan-March on the roadmap (as we switch from goal one which is webpackification to the next goal which is refactoring). We need to first work out what our future with or without template looks like, but I suspect one outcome of this is to either get rid of Hogan or Mustache.

Where possible, said tasks should rename Hogan.js and Mustache file extensions to the implementation type, .mustache.

The problem with this, is if these templates then get loaded on the client, they will load the Mustache library (on top of Hogan). That's how ResourceLoader works. It's based on file extension.

The problem we have is that many templates are both hogan AND mustache (and used in both contexts. Since hogan is a superset of mustache and we don't want the Mustache library on mobile, we used the hogan extension name.

Jdlrobson raised the priority of this task from Normal to Needs Triage.Jan 3 2019, 10:39 PM
Krinkle added a subscriber: Krinkle.EditedMar 19 2019, 6:57 PM

[..] We need to first work out what our future with or without template looks like, but I suspect one outcome of this is to either get rid of Hogan or Mustache.

! @Niedzielski wrote:
Where possible, said tasks should rename Hogan.js and Mustache file extensions to the implementation type, .mustache.

The problem with this, is if these templates then get loaded on the client, they will load the Mustache library (on top of Hogan). That's how ResourceLoader works. It's based on file extension.

Registering two template systems with two different modules, and using them both, will naturally load both modules.

The problem we have is that many templates are both hogan AND mustache (and used in both contexts. Since hogan is a superset of mustache and we don't want the Mustache library on mobile, we used the hogan extension name.

Hogan is unmaintained.
Hogan is not the library we agreed to standardise on (RFC). This was approved with your involvement in 2014.
Hogan is marginally larger (in terms of bandwidth transfer size) per T94086#4525712. Although as mentioned there, transfer size seems to be a very weak argument considering the tiny difference.
Hogan's existence in production is blocking T127268.

Mustache is the opposite of all these, and as such, what MediaWiki core and other extensions use server-side and client-side. And Mustache is also what MobileFrontend and Minerva already use server-side.

It seems that the simplest solution here would be to use Mustache client-side on mobile as well. It solves all mentioned problems. What am I missing?

Niedzielski reopened this task as Open.Apr 2 2019, 12:43 AM

I think this task is distinct from T219845.

I must confess I don't understand this task as written. Given Hogan is now gone can you have a go at editing the description.

I'm not aware of any duplicate templates. Where templates can be shared between server and client they are and where they can't it's because they don't need to be.

Thanks in advance!

Niedzielski closed this task as Declined.May 3 2019, 4:27 PM