通过在build.xml文件中使用以下代码块
<propertyfile file="default.properties" comment="Default properties">
<entry key="source.dir" value="1" />
<entry key="dir.publish" value="1" />
<entry key="dir.publish.html" value="1" />
</propertyfile>
Run Code Online (Sandbox Code Playgroud)
我能够生成default.properties包含以下文件内容的文件
source.dir=1
dir.publish=1
dir.publish.html=1
Run Code Online (Sandbox Code Playgroud)
我想知道如何在生成的文件中添加我的评论?例如,生成的属性应具有以下内容:
# Default Configuration
source.dir=1
dir.publish=1
# Source Configuration
dir.publish.html=1
Run Code Online (Sandbox Code Playgroud)
我怎样才能使用Ant动态地做到这一点build.xml?
我有以下代码通过HTML5 File API读取文件.我通过input = file element上传了文件.以下是代码块.
<input type="file" id="files" name="file" />
<button id="readFile">Read File</button>
<output id="content"></output>
<script>
function readFile()
{
/* Get the reference of the inpout element. */
var files = document.getElementById('files').files;
console.log(files);
if (!files.length)
{
alert('Please select a file!');
return;
}
/* Reading the first file selected. You can process other files similarly in loop. */
var file = files[0];
/* Instantiate the File Reader object. */
var reader = new FileReader();
/* onLoad event is fired when …Run Code Online (Sandbox Code Playgroud) 以下是我正在处理的bat脚本代码块:
ECHO off
IF NOT EXIST "%ANT_HOME%" (
SET ANT_HOME=%~dp0%build\apache-ant-1.8.2
SET ANT_BIN=%~dp0%build\apache-ant-1.8.2\bin
SET PATH | FIND "%ANT_HOME%;%ANT_BIN%"
)
cd "build\Run"
ant -q
cd ../..
echo "Program Terminated!"
exit
Run Code Online (Sandbox Code Playgroud)
现在,我的build.xml文件位于此build\Run文件夹中,因此我在运行ant -q命令之前首先导航到构建/运行(注意:我不想更改此导航方法).
事件发生后执行ant -q命令:
cd../.. 但问题是我无法在ant -q之后执行命令.这发生在程序控制来自BATCH => ANT.
有没有办法在bat脚本本身的ant命令后执行我的命令?
我正在开发一些基于Backbone的项目,我正在使用i18next进行语言环境.
以下是我的app.js代码:
/*
This file is used to initialize your application.
*/
require(['i18n','application','handlebars_Helpers'], function(i18n, Application) {
i18n.init({
lng: 'en',
debug: true,
fallbackLng: false,
load:'unspecific',
resGetPath: "locales/__lng__/__ns__.json",
ns: {
namespaces: ['translation']
}
});
(new Application()).initialize();
});
Run Code Online (Sandbox Code Playgroud)
翻译文件:
{
"loginModule": {
"signin": "Sign In"
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我的帮助文件:
/**
* Set of generic handlebars helpers
*/
define(['i18n'], function(i18n) {
/**
* This helper provides i18Next in templates
*
*
* Usage: span {{t "my.key" }}
*/
Handlebars.registerHelper('t', function(i18n_key) {
var result = i18n.t(i18n_key); …Run Code Online (Sandbox Code Playgroud) 我只是在NodeJS上尝试一些代码,我是NodeJS的新手.我写了下面的代码块.
var fs = require('fs'),
os = require('os');
var filename = 'Server.ini';
var serverData = os.hostname() + "\n" + os.platform() + "\n" + os.type() + "\n";
fs.existsSync(filename, function(exists) {
if(exists) {
console.log("1. " + filename + " file found. Server needs to be updated.")
fs.unlinkSync(filename, function(error) {
if(error) throw error;
console.log("2. " + filename + " is been unlinked from server.");
});
} else {
console.log("1. " + filename + " not found.");
console.log("2. Server needs to be configured.");
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Apache Ant处理一些项目,我的项目布局如下:
project/build.xml
project/properties/build.properties
project/tool/antcontrib.jar
Run Code Online (Sandbox Code Playgroud)
在这里,当我运行ant命令它工作正常,我的基目录是basedir ="."
现在,我希望我的项目布局如下:
project/folder/build.xml
project/properties/build.properties
project/tool/antcontrib.jar
Run Code Online (Sandbox Code Playgroud)
现在,我将基本目录更改为basedir ="..".我认为它可能会奏效.但它仍然不起作用.所以我不知道我们必须为'../'设置我们的基础.这是与我的build.xml文件中定义的taskdef相关的代码块.
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${tool.ant.contrib}"/>
</classpath>
</taskdef>
Run Code Online (Sandbox Code Playgroud)
注意:我知道build.xml和属性文件应该在同一文件夹中作为标准做法.但我不想这样做......任何人都可以帮助我...
index.html文件如下:此HTML使用Handlebars编译
<div id="svg"></div>
Run Code Online (Sandbox Code Playgroud)
index.js文件如下:
var s = Snap("#svg");
var bigCircle = s.circle(150, 150, 100);
Run Code Online (Sandbox Code Playgroud)
当我执行我的代码.它显示以下错误:
TypeError: s.circle is not a function
Run Code Online (Sandbox Code Playgroud) 我正在研究Apache ANT上的一些代码块
<target name="workload">
<script language="javascript"><![CDATA[
println("<div id='collapseOne' class='accordion-body collapse in'><div class='accordion-inner'><pre>"); ]]>
</script>
<apply dir="${dir.publish.ini}" executable="java" parallel="false" failonerror="false">
<fileset dir="${dir.ini}">
<include name="**/*.ini"/>
</fileset>
<arg value="-jar" />
<arg path="${tool}" />
<srcfile/>
</apply>
<script language="javascript"><![CDATA[ println("</pre></div></div>"); ]]></script>
</target>
Run Code Online (Sandbox Code Playgroud)
当我使用<antcall target="workload"/>
它工作正常.
我必须优化此代码块.所以我尝试使用以下代码:
<macrodef name="workload">
<script language="javascript"><![CDATA[
println("<div id='collapseOne' class='accordion-body collapse in'><div class='accordion-inner'><pre>"); ]]>
</script>
<apply dir="${dir.publish.html}" executable="java" parallel="false" failonerror="false">
<fileset dir="${dir.ini}">
<include name="**/*.ini"/>
</fileset>
<arg value="-jar" />
<arg path="${tool}" />
<srcfile/>
</apply>
<script language="javascript"><![CDATA[ println("</pre></div></div>"); ]]></script>
</macrodef>
Run Code Online (Sandbox Code Playgroud)
当我打电话时<antcall target="workload"/> …
我已经开始使用Backbone了.
在学习Backbone时,我知道使用.listenTo代替.on的优点是listenTo允许"对象跟踪事件".
我没听到这句话试图说的话.好吧,我只能看到.on和.listenTo之间的区别是关于语法.
哪一个是JavaScript的最佳实践?为什么?
1>
一个) var object = this.table.toJSON();
要么
b)
var object = {};
object = this.table.toJSON();
Run Code Online (Sandbox Code Playgroud)
2>
一个)
var keySelected = "";
Run Code Online (Sandbox Code Playgroud)
要么
b) var keySelected = null;
ant ×4
backbone.js ×2
java ×2
javascript ×2
batch-file ×1
html5 ×1
i18next ×1
jquery ×1
node.js ×1
requirejs ×1
snap.svg ×1