Skip to main content Svelte Highlight v7.21.1

Jsonnet language preview

1. Config templating

locals, functions, and the std library
horizon-dark
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}
atom-one-dark
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}
github-dark
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}
dracula
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}
nord
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}
github
local name = "frontend";
local replicas = 3;

{
  apiVersion: "apps/v1",
  kind: "Deployment",
  metadata: {
    name: name,
    labels: { app: name },
  },
  spec: {
    replicas: replicas,
    template: {
      spec: {
        containers: [
          { name: name, image: "registry/" + name + ":latest" },
        ],
      },
    },
  },
}

2. Functions and comprehensions

object construction and std.map
horizon-dark
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}
atom-one-dark
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}
github-dark
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}
dracula
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}
nord
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}
github
local mkPort(p) = { containerPort: p, protocol: "TCP" };

{
  ports: std.map(mkPort, [80, 443, 8080]),
  count: std.length(self.ports),
}

3. Hidden fields and verbatim strings

field-visibility operators (::, +:) and @"..." escaping
horizon-dark
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}
atom-one-dark
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}
github-dark
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}
dracula
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}
nord
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}
github
local helper = @"a ""quoted"" value";

{
  visible: "shown in output",
  hidden:: "omitted from output",
  computed+: { extra: true },
  note: helper,
}