Jump to content

Template:Content Patcher example/doc: Difference between revisions

From Stardew Valley Wiki
imported>Pathoschild
tweak header
imported>Pathoschild
→Description: + escape MediaWiki syntax
Line 30: Line 30:
     ]
     ]
}}
}}
===Escape MediaWiki syntax===
If your code example includes <code><nowiki>{{</nowiki></code> or <code><nowiki>[[</nowiki></code>, you'll need to disable MediaWiki syntax using <code>&lt;nowiki&gt;</code>.
For example, this template usage:
<pre>{{Content Patcher example|&lt;nowiki&gt;
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "{{animation Id}}/50/50"
            }
        }
    ]
&lt;/nowiki&gt;}}</pre>
Will produce this code example:
{{Content Patcher example|<nowiki>
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "{{animation Id}}/50/50"
            }
        }
    ]
</nowiki>}}


<includeonly>
<includeonly>

Revision as of 19:03, 1 February 2025

Description

This template outputs an example Content Patcher content.json structure with the latest Format version.

Usage

Just call the template with the top-level Content Patcher fields you want to display (except Format). These should be indented once with four spaces.

For example, this template usage:

{{Content Patcher example|
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "50/50/50"
            }
        }
    ]
}}

Will produce this code example:

{
    "Format": "2.8.0",
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "50/50/50" // note: make name lowercase
            }
        }
    ]
}

Escape MediaWiki syntax

If your code example includes {{ or [[, you'll need to disable MediaWiki syntax using <nowiki>.

For example, this template usage:

{{Content Patcher example|<nowiki>
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "{{animation Id}}/50/50"
            }
        }
    ]
</nowiki>}}

Will produce this code example:

{
    "Format": "2.8.0",
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/animationDescriptions",
            "Entries": {
                "pufferbob_sleep": "{{animation Id}}/50/50"
            }
        }
    ]
}