在ERB模式下获取HTML代码段/建议(VSCode)

时间:2018-12-24 15:31:42

标签: visual-studio-code

在ERB语言模式下,我想使用所有的html和emmett快捷方式/摘录。我通常会根据当前所需的标签类型在HTML模式和ERB模式之间来回切换,但这很痛苦,我也希望始终使用ERB代码颜色。有没有简单的方法可以做到这一点?

2 个答案:

答案 0 :(得分:2)

我对ERB一无所知,但是您可以尝试进行以下设置吗:

"emmet.includeLanguages": { "ruby": "html" } 

或类似的emmet功能。

另一种可能性是将ERB文件与html ala相关联:

"files.associations": { "*.ERB" : "html" } 

答案 1 :(得分:0)

    func uploadImage(image: UIImage)
{

    let url = URL(string: "URL_TO_PHP_SERVER");
    let request = NSMutableURLRequest(url: url!)
    request.httpMethod = "POST"

    let boundary = generateBoundaryString()

    //define the multipart request type

    request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

    let image_data = UIImageJPEGRepresentation(image, 1)


    if(image_data == nil)
    {
        print("problem occurred")
        return;
    }


    let body = NSMutableData();

    let date = Date();
    let fname = "\(Int64(date.timeIntervalSince1970*1000)).jpg"
    print("file name: \(fname)");
    let mimetype = "image/jpeg"

    //define the data post parameter

    body.append("--\(boundary)\r\n".data(using: String.Encoding.utf8)!)
    body.append("Content-Disposition:form-data; name=\"test\"\r\n\r\n".data(using: String.Encoding.utf8)!)
    body.append("hi\r\n".data(using: String.Encoding.utf8)!)

    body.append("--\(boundary)\r\n".data(using: String.Encoding.utf8)!)
    body.append("Content-Disposition:form-data; name=\"file\"; filename=\"\(fname)\"\r\n".data(using: String.Encoding.utf8)!)
    body.append("Content-Type: \(mimetype)\r\n\r\n".data(using: String.Encoding.utf8)!)
    body.append(image_data!)
    body.append("\r\n".data(using: String.Encoding.utf8)!)


    body.append("--\(boundary)--\r\n".data(using: String.Encoding.utf8)!)



    request.httpBody = body as Data


    //        let session = NSURLSession.sharedSession()
    var configuration = URLSessionConfiguration.default;
    var session = URLSession(configuration: configuration, delegate: self, delegateQueue: OperationQueue.main);


    let task = session.dataTask(with: request as URLRequest) {
        (
        data, response, error) in

        guard let _:Data = data, let _:URLResponse = response, error == nil else {
            print("error")
            DispatchQueue.main.async {
                print("Problem occurred in uploading");
                // DO your stuff in UI Thread
            }
            return
        }

        DispatchQueue.main.async {
            print("uploading success");
            // DO your stuff in UI Thread
        }

        let dataString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
        print(dataString)

    }

    task.resume()


}

它不起作用

但是如果将“ ruby​​”更改为“ erb”,则可以正常工作。

"emmet.includeLanguages": { "ruby": "html" } 

在Mac中,键入"emmet.includeLanguages": { "erb": "html" } ,打开设置json。并添加上选项或更改它。