小编Cha*_*shu的帖子

如何使用maven缩小过滤的javascript文件?

我有一个javascript文件,用于使用Google分析跟踪事件.我为登台和生产环境创建了不同的帐户.调用GA代码的脚本有我的帐户ID的占位符.帐户ID已在过滤器文件中指定.使用maven-war插件中的webResources元素,我们能够成功替换最终WAR文件中的属性.

现在,我们还使用maven-yuicompressor插件来缩小和聚合我们所有的javascript文件.问题是,如果我将minify目标的执行附加到包阶段,则在Javascript缩小之前创建WAR.如果我将minify目标附加到任何更早的目标,则直到缩小产生无效文件时才会应用过滤器.

所以,我正在寻找一种方法来运行复制过滤后的JS文件的WAR插件和创建WAR文件之间的minify目标.以下是我的pom.xml的相关部分:

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
              <webResources>
                <resource>
                  <directory>src/main/webapp/js</directory>
                  <targetPath>js</targetPath>
                  <filtering>true</filtering>
                </resource>
              </webResources>
            </configuration>
          </plugin>
          <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>compress</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
            <configuration>
              <linebreakpos>-1</linebreakpos>
              <nosuffix>true</nosuffix>
              <force>true</force>
              <aggregations>
                <aggregation>
                  <output>${project.build.directory}/${project.build.finalName}/js/mysite-min.js</output>
                  <inputDir>${project.build.directory}/${project.build.finalName}/js</inputDir>
                  <includes>
                    <include>jquery-1.4.2.js</include>
                    <include>jquery-ui.min.js</include>
                    <include>ga-invoker.js</include>
                  </includes>
                </aggregation>
              </aggregations>
            </configuration>
          </plugin>
Run Code Online (Sandbox Code Playgroud)

javascript filter minify maven

14
推荐指数
2
解决办法
9619
查看次数

Zurb基金会比Twitter Bootstrap好吗?

Zurb Foundation在哪些方面提供比Bootstrap更多的功能或特性?

twitter-bootstrap zurb-foundation

12
推荐指数
1
解决办法
1万
查看次数

如何在Rspec 2中测试渲染:file =>'public/404.html'?

我在一个动作中有以下代码:

render :file => 'public/404.html' and return
Run Code Online (Sandbox Code Playgroud)

这在浏览器中工作正常.我写了以下rspec示例来测试这个:

  it "renders 404" do
    get :new
    response.should render_template('public/404.html')
  end
Run Code Online (Sandbox Code Playgroud)

运行此示例会导致以下错误:

 Failure/Error: response.should render_template('public/404.html')
   Expected block to return true value.
Run Code Online (Sandbox Code Playgroud)

我也试过,response.should render_template(:file => 'public/404.html')但这也导致错误.

我该怎么测试呢?

testing rspec ruby-on-rails

10
推荐指数
2
解决办法
1万
查看次数

jQuery使用数组中的数据创建选择标签

我需要访问数据库并更新选择标记的选项。我的代码在这里。

 $(window).load(function () {

     $.getJSON('http://localhost/ABC/web/app_dev.php/doctorFillOption', function (data) {

         var length = data.length,
             element = null;
         $('#idcatFill').append('<select id ="idCat"  style="width:200px;margin-left:30px;margin-top:5px;" type="text"><option value=""></option>');

         for (var i = 0; i < length; i++) {
             row = data[i];
             alert("id" + row['id'] + ' ' + row['category_name']);
             $('#idcatFill').append(
                 '<option value="' + row['id'] + '">' + row['category_name'] + '</option>'
             );
         }

     });
     $('#idcatFill').append('</select><br/>');
 });
Run Code Online (Sandbox Code Playgroud)

但是它没有选择权。需要帮忙。谢谢。

html jquery symfony

5
推荐指数
2
解决办法
2584
查看次数