Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{ file_name }} undefined when create a new file. #20

Closed
jimzhan opened this issue Sep 15, 2014 · 7 comments
Closed

{{ file_name }} undefined when create a new file. #20

jimzhan opened this issue Sep 15, 2014 · 7 comments

Comments

@jimzhan
Copy link

jimzhan commented Sep 15, 2014

{{ file_name }} is undefined when directly create a new file, adding header existing file works fine in the meantime.

@shiyanhui
Copy link
Owner

file_name经测试在ST2/ST3都是没问题的。出现这种情况可能是你创建文件的时候没有命名。

@jimzhan
Copy link
Author

jimzhan commented Sep 15, 2014

最新的 Build 3065 重新安裝,新建文件 test.go。出現問題相同,而且通過 FileHeader 創建文件時必須要先命名,所以並沒有你所提的情況。

@shiyanhui
Copy link
Owner

你能具体描述下问题出现的过程(你的操作)吗?

@jimzhan
Copy link
Author

jimzhan commented Sep 15, 2014

  1. super+alt+n (通过 FileHeader 新建文件) => test.go
  2. FileHeader/template/Header/Go.tmpl

// ------------------------------------------------------------
// @project {{ project_name }}
// @file {{ file_name }}
// @Date {{ create_time }}
// @author {{ author }} <{{ email }}>
//
// Copyright {{ copyright }} {{ create_time[0:4] }} {{ author }}.
// ------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------

結果是 {{ file_name }} undefined, 同一 header 添加到已建立的文件時沒有問題。

@shiyanhui
Copy link
Owner

问题是这样出现的:当你使用快捷键创建一个new file时,如果当前你没有打开一个view(简单来说就是一个tab),通过api你是获取不到文件名的。所以请你先打开你的项目,再通过快捷键或者左侧栏sub menu创建新文件。新文件的位置和你当前浏览的文件在同一文件夹。

@jimzhan
Copy link
Author

jimzhan commented Sep 15, 2014

上面的操作都是在 Project 打開並己有打開文件的基礎上進行的。

@shiyanhui
Copy link
Owner

不应该啊,麻烦你测试下通过侧栏创建有没有问题,方法:右键点击侧栏project->File Header->New File。谢谢了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants