2
$\begingroup$

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?

$\endgroup$

1 Answer 1

4
$\begingroup$

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 метра

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.