我想在Atom中使用自己的代码段,但是经过数小时的尝试,我仍然不能使用其中的前两个代码段,而且我找不到错误。
在寻找解决方案时,我发现了很多主题,但是每个主题中的错误都是重复使用源范围,但这不是我的问题。实际上,我几乎尝试了所有操作,对语法进行了许多更改,但没有任何帮助。
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="$1">
<meta name="author" content="MagicDev">
<meta name="keywords" content="$2">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title>$3</title>
</head>
<body>
$4
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "$1";
$username = "$2";
$password = "$3";
$dbname = "$4";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>$5
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();$1"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();$6
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags($1)"
有人可以救我吗?我在俯视什么?
答案 0 :(得分:0)
就像CoffeeScript一样,CSON(CoffeeScript对象表示法)对缩进敏感。您的示例中的前两个代码段已正确缩进,接下来的代码段太深了。
如果您不熟悉基于缩进的语言(和格式),建议您使用linter-coffeelint
。它标记了各种语法错误。
示例:
如果您对使用JSON感到更自在,Atom还支持以该格式保存的代码段。
最后,这是您的带有正确缩进的代码段:
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="$1">
<meta name="author" content="MagicDev">
<meta name="keywords" content="$2">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title>$3</title>
</head>
<body>
$4
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "$1";
$username = "$2";
$password = "$3";
$dbname = "$4";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>$5
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();$1"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();$6
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags($1)"