Code Snippet

Code Snippet Modul für die Darstellung von Code Snippets

Das Code Snippet Modul wird verwendet, um kurze Code Snippets auf einer Seite darzustellen. Das Modul bietet den Usern die Möglichkeit das dargestellte Snippet direkt zu kopieren. 

HTML Snippet

<!DOCTYPE html>
<html>
<body>

<h2>The select Element</h2>
<p>The select element defines a drop-down list:</p>

<form action="/action_page.php">
  <select name="cars">
    <option value="v1">Item1</option>
    <option value="v2">Item2</option>
    <option value="v3">Item3</option>
    <option value="v4">Item4</option>
  </select>
  <br><br>
  <input type="submit">
</form>

</body>
</html>

JavaScript Snippet

function noisy(f) {
  return (...args) => {
    console.log("calling with", args);
    let result = f(...args);
    console.log("called with", args, ", returned", result);
    return result;
  };
}
noisy(Math.min)(3, 2, 1);
// → calling with [3, 2, 1]
// → called with [3, 2, 1] , returned 1

Go Snippet

package main

import (
	"fmt"
	"math/cmplx"
)

var (
	ToBe   bool       = false
	MaxInt uint64     = 1<<64 - 1
	z      complex128 = cmplx.Sqrt(-5 + 12i)
)

func main() {
	fmt.Printf("Type: %T Value: %v\n", ToBe, ToBe)
	fmt.Printf("Type: %T Value: %v\n", MaxInt, MaxInt)
	fmt.Printf("Type: %T Value: %v\n", z, z)
}