2

How to overwrite the display function of TemplateBox? For example, if I have:

NotebookWrite[InputNotebook[],  ToBoxes@Quantity[3, "Meters"]]

how do I overwrite the DisplayFunction to make the out put display differently, without changing the actual value of the output?

RunnyKine
  • 33,088
  • 3
  • 109
  • 176
Yituo
  • 1,389
  • 9
  • 15

1 Answers1

4

Boxes are just like any other expression when they are evaluated by the kernel, so one way to achieve this is with replacement rules:

ToBoxes@Quantity[3, "Meters"] /.
  (DisplayFunction -> _) -> (DisplayFunction -> (RowBox@{#1, " метра"} &)) // RawBoxes

3 метра

mfvonh
  • 8,460
  • 27
  • 42